/** * Releases an existing connection (paying special attention to {@link Transaction#AUTO_COMMIT}. * * <p>If the state is based off the AUTO_COMMIT transaction - close using {@link * #closeSafe(Connection)}. Otherwise wait until the transaction itself is closed to close the * connection. */ protected final void releaseConnection(Connection cx, JDBCState state) { if (state.getTransaction() == Transaction.AUTO_COMMIT) { closeSafe(cx); } }
/** * Creates an instanceof {@link JDBCState}. * * @see ContentDataStore#createContentState(ContentEntry) */ protected ContentState createContentState(ContentEntry entry) { JDBCState state = new JDBCState(entry); state.setExposePrimaryKeyColumns(exposePrimaryKeyColumns); return state; }
JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); if (state.getPrimaryKey() == null) { synchronized (this) { if (state.getPrimaryKey() == null) { state.setPrimaryKey(pkey); } catch (SQLException e) { String msg = "Error looking up primary key"; return state.getPrimaryKey();
/** Creates the state from an existing one. */ public JDBCState(JDBCState state) { super(state); // copy the primary key primaryKey = state.getPrimaryKey(); exposePrimaryKeyColumns = state.isExposePrimaryKeyColumns(); }
if(state.getTransaction() == Transaction.AUTO_COMMIT) { Connection cx = createConnection(); try { Connection cx = state.getConnection(); if (cx == null) { synchronized (state) { state.setConnection(cx); state.getTransaction().putState(state, new JDBCTransactionState( cx, this ) );
/** Copies the state. */ public ContentState copy() { return new JDBCState(this); } }
/** * The flag which will expose columns which compose a tables identifying or primary key, through * feature type attributes. */ public boolean isExposePrimaryKeyColumns() { return ((JDBCState) entry.getState(transaction)).isExposePrimaryKeyColumns(); }
/** * Creates the state from an existing one. */ public JDBCState(JDBCState state) { super(state); //copy the primary key primaryKey = state.getPrimaryKey(); //do not copy the connection //connection = state.getConnection(); }
/** * Sets the flag which will expose columns which compose a tables identifying or primary key, * through feature type attributes. * * <p>Note: setting this flag which affect all feature sources created from or working against * the current transaction. */ public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) { ((JDBCState) entry.getState(transaction)) .setExposePrimaryKeyColumns(exposePrimaryKeyColumns); }
/** * Creates the state from an existing one. */ public JDBCState(JDBCState state) { super(state); //copy the primary key primaryKey = state.getPrimaryKey(); exposePrimaryKeyColumns = state.isExposePrimaryKeyColumns(); }
/** * Copies the state. */ public ContentState copy() { return new JDBCState(this); }
/** * Returns the expose primary key columns flag for the specified feature type * * @param featureType * @return * @throws IOException */ protected boolean isExposePrimaryKeyColumns(SimpleFeatureType featureType) throws IOException { ContentEntry entry = ensureEntry(featureType.getName()); JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); return state.isExposePrimaryKeyColumns(); }
/** * Sets the flag which will expose columns which compose a tables identifying or primary key, * through feature type attributes. * <p> * Note: setting this flag which affect all feature sources created from or working against * the current transaction. * </p> */ public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) { ((JDBCState)entry.getState(transaction)).setExposePrimaryKeyColumns(exposePrimaryKeyColumns); }
/** Gets a database connection for the specified feature store. */ protected final Connection getConnection(JDBCState state) throws IOException { return getConnection(state.getTransaction()); }
JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); if (state.getPrimaryKey() == null) { synchronized (this) { if (state.getPrimaryKey() == null) { state.setPrimaryKey(pkey); } catch (SQLException e) { String msg = "Error looking up primary key"; return state.getPrimaryKey();
/** * Creates an instanceof {@link JDBCState}. * * @see ContentDataStore#createContentState(ContentEntry) */ protected ContentState createContentState(ContentEntry entry) { JDBCState state = new JDBCState(entry); state.setExposePrimaryKeyColumns(exposePrimaryKeyColumns); return state; }
/** * Copies the state. */ public ContentState copy() { return new JDBCState(this); }
columnNames = new String[count]; exposePrimaryKeys = featureSource.getState().isExposePrimaryKeyColumns(); for (int i = 0; i < md.getColumnCount(); i++) { String columnName = md.getColumnName(i + 1);
Connection cx = getDataStore().getConnection(getState().getTransaction()); if (getState().getTransaction() == Transaction.AUTO_COMMIT) { cx.setAutoCommit(false);
JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); if (state.getPrimaryKey() == null) { synchronized (this) { if (state.getPrimaryKey() == null) { state.setPrimaryKey(pkey); } finally { closeSafe(primaryKey); return state.getPrimaryKey();