sascha@229: package de.intevation.artifactdatabase.h2; sascha@229: sascha@229: import org.h2.api.Trigger; sascha@229: sascha@229: import java.sql.Connection; sascha@229: import java.sql.SQLException; sascha@229: import java.sql.PreparedStatement; sascha@229: sascha@305: import de.intevation.artifactdatabase.DBConfig; sascha@305: sascha@305: import de.intevation.artifactdatabase.db.SQL; sascha@229: sascha@229: import org.apache.log4j.Logger; sascha@229: sascha@229: public class CollectionAccessUpdateTrigger sascha@229: implements Trigger sascha@229: { sascha@229: private static Logger logger = sascha@229: Logger.getLogger(CollectionAccessUpdateTrigger.class); sascha@229: sascha@305: public String COLLECTIONS_TOUCH_TRIGGER_FUNCTION; sascha@229: sascha@229: public void init( sascha@229: Connection conn, sascha@229: String schemaName, sascha@229: String triggerName, sascha@229: String tableName, sascha@229: boolean before, sascha@229: int type sascha@233: ) sascha@229: throws SQLException { sascha@229: logger.debug("CollectionAccessUpdateTrigger.init"); sascha@305: setupSQL(DBConfig.getInstance().getSQL()); sascha@305: } sascha@305: sascha@305: protected void setupSQL(SQL sql) { sascha@305: COLLECTIONS_TOUCH_TRIGGER_FUNCTION = sascha@305: sql.get("collections.touch.trigger.function"); sascha@229: } sascha@229: sascha@229: public void fire( sascha@233: Connection conn, sascha@229: Object [] oldRow, sascha@229: Object [] newRow sascha@229: ) sascha@229: throws SQLException { sascha@229: logger.debug("CollectionAccessUpdateTrigger.fire"); sascha@229: PreparedStatement stmnt = conn.prepareStatement( sascha@229: COLLECTIONS_TOUCH_TRIGGER_FUNCTION); sascha@229: stmnt.setObject(1, newRow[0]); sascha@229: stmnt.execute(); sascha@229: stmnt.close(); sascha@229: } sascha@229: sascha@229: public void close() throws SQLException { sascha@229: logger.debug("CollectionAccessUpdateTrigger.close"); sascha@229: } sascha@229: sascha@229: public void remove() throws SQLException { sascha@229: logger.debug("CollectionAccessUpdateTrigger.remove"); sascha@229: } sascha@229: } sascha@229: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :