Code example for Connection

Methods: getMetaData

0
        prepInsert = conn.prepareStatement("insert into test_data values(?, ?, ?)");
        super.init(conn, schemaName, triggerName, tableName, before, type);
    } 
 
    public void fire(Connection conn, ResultSet oldRow, ResultSet newRow) throws SQLException {
        String user = conn.getMetaData().getUserName();
        if (oldRow != null && oldRow.next()) {
            prepDelete.setInt(1, oldRow.getInt(1));
            prepDelete.setString(2, user);
            int deleted = prepDelete.executeUpdate();
            if (deleted == 0 && newRow != null) {
                // update: 
                // if deleting failed, insert must fail as well 
                newRow = null;
            } 
        } 
        if (newRow != null && newRow.next()) {
            prepInsert.setInt(1, newRow.getInt(1));
            prepInsert.setString(2, user);
            prepInsert.setString(3, newRow.getString(2));
Stop searching for code, let great code find you!  Add Codota to your java IDE