comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/h2/CollectionAccessUpdateTrigger.java @ 473:d0ac790a6c89 dive4elements-move

Moved directories to org.dive4elements
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 10:57:18 +0200
parents artifact-database/src/main/java/de/intevation/artifactdatabase/h2/CollectionAccessUpdateTrigger.java@f33401ea2a6c
children 415df0fc4fa1
comparison
equal deleted inserted replaced
472:783cc1b6b615 473:d0ac790a6c89
1 package de.intevation.artifactdatabase.h2;
2
3 import org.h2.api.Trigger;
4
5 import java.sql.Connection;
6 import java.sql.SQLException;
7 import java.sql.PreparedStatement;
8
9 import de.intevation.artifactdatabase.DBConfig;
10
11 import de.intevation.artifactdatabase.db.SQL;
12
13 import org.apache.log4j.Logger;
14
15 public class CollectionAccessUpdateTrigger
16 implements Trigger
17 {
18 private static Logger logger =
19 Logger.getLogger(CollectionAccessUpdateTrigger.class);
20
21 public String COLLECTIONS_TOUCH_TRIGGER_FUNCTION;
22
23 public void init(
24 Connection conn,
25 String schemaName,
26 String triggerName,
27 String tableName,
28 boolean before,
29 int type
30 )
31 throws SQLException {
32 logger.debug("CollectionAccessUpdateTrigger.init");
33 setupSQL(DBConfig.getInstance().getSQL());
34 }
35
36 protected void setupSQL(SQL sql) {
37 COLLECTIONS_TOUCH_TRIGGER_FUNCTION =
38 sql.get("collections.touch.trigger.function");
39 }
40
41 public void fire(
42 Connection conn,
43 Object [] oldRow,
44 Object [] newRow
45 )
46 throws SQLException {
47 logger.debug("CollectionAccessUpdateTrigger.fire");
48 PreparedStatement stmnt = conn.prepareStatement(
49 COLLECTIONS_TOUCH_TRIGGER_FUNCTION);
50 stmnt.setObject(1, newRow[0]);
51 stmnt.execute();
52 stmnt.close();
53 }
54
55 public void close() throws SQLException {
56 logger.debug("CollectionAccessUpdateTrigger.close");
57 }
58
59 public void remove() throws SQLException {
60 logger.debug("CollectionAccessUpdateTrigger.remove");
61 }
62 }
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org