@Override public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { final TableLocation notificationTable = new TableLocation(TRIGGER_SCHEMA, NOTIFICATION_TABLE); try { PreparedStatement st = conn.prepareStatement("INSERT INTO "+notificationTable+"(idtrigger) VALUES(?)"); st.setInt(1, idTrigger); try { st.execute(); } finally { st.close(); } } catch (Exception ex) { // Ignore exception to not interfere with database } }
@Override public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { final TableLocation notificationTable = new TableLocation(TRIGGER_SCHEMA, NOTIFICATION_TABLE); try { PreparedStatement st = conn.prepareStatement("INSERT INTO "+notificationTable+"(idtrigger) VALUES(?)"); st.setInt(1, idTrigger); try { st.execute(); } finally { st.close(); } } catch (Exception ex) { // Ignore exception to not interfere with database } }
@Override public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { this.update = type == UPDATE; this.tableIdentifier = new TableLocation(schemaName, tableName).toString(true); if(!dataManager.hasTableEditListener(tableIdentifier)) { try(Statement st = conn.createStatement()) { st.execute("DROP TRIGGER IF EXISTS "+triggerName); } throw new SQLException("This trigger does not exists"); } }
public Layer(String name, URI dataURI,DataManager dataManager) { super(name); this.dataURI = dataURI; this.dataManager = dataManager; if(JDBC_REFERENCE_SCHEME.equalsIgnoreCase(dataURI.getScheme())) { try { Map<String,String> query = URIUtility.getQueryKeyValuePairs(URI.create(dataURI.getSchemeSpecificPart())); tableReference = new TableLocation(query.get("catalog"),query.get("schema"),query.get("table")).toString(); } catch (UnsupportedEncodingException ex) { LOGGER.trace(ex.getLocalizedMessage(), ex); } } }
@Override public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { this.update = type == UPDATE; this.tableIdentifier = new TableLocation(schemaName, tableName).toString(true); if(!dataManager.hasTableEditListener(tableIdentifier)) { try(Statement st = conn.createStatement()) { st.execute("DROP TRIGGER IF EXISTS "+triggerName); } throw new SQLException("This trigger does not exists"); } else { // Fetch primary key column pkColumn = JDBCUtilities.getIntegerPrimaryKey(conn, tableIdentifier); } }
@Override public boolean hasTableEditListener(String tableIdentifier) { TableLocation table = TableLocation.parse(tableIdentifier, isH2); if("PUBLIC".equals(table.getSchema()) && !tableEditionListener.containsKey(table.toString(true))) { // Maybe schema is not given in listener table identifier table = new TableLocation("","",table.getTable()); } String parsedTable = table.toString(isH2); return tableEditionListener.containsKey(parsedTable); }
@Override public boolean hasTableEditListener(String tableIdentifier) { TableLocation table = TableLocation.parse(tableIdentifier, isH2); if("PUBLIC".equals(table.getSchema()) && !tableEditionListener.containsKey(table.toString(true))) { // Maybe schema is not given in listener table identifier table = new TableLocation("","",table.getTable()); } String parsedTable = table.toString(isH2); return tableEditionListener.containsKey(parsedTable); }
private static String getH2TriggerName(String table) { TableLocation tableIdentifier = TableLocation.parse(table, true); return new TableLocation(tableIdentifier.getCatalog(), tableIdentifier.getSchema(), "DM_"+tableIdentifier.getTable()).toString(true); } @Override
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); } }
private static String getH2TriggerName(String table) { TableLocation tableIdentifier = TableLocation.parse(table, true); return new TableLocation(tableIdentifier.getCatalog(), tableIdentifier.getSchema(), "DM_"+tableIdentifier.getTable()).toString(true); } @Override
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); }
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); }
@Override public String findUniqueTableName(String originalTableName) throws SQLException { TableLocation tableLocation = TableLocation.parse(originalTableName); String tableName = originalTableName; int offset = 0; while(isTableExists(tableName)) { tableName = new TableLocation(tableLocation.getCatalog(), tableLocation.getSchema(), tableLocation.getTable() + "_" + ++offset).toString(); } return tableName; }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ private static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ private static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ public static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); } }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * * @return Find table identifier */ public static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); } }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }