/** * Create a new ConnectionHolder for the given JDBC Connection, * wrapping it with a {@link SimpleConnectionHandle}, * assuming that there is no ongoing transaction. * @param connection the JDBC Connection to hold * @see SimpleConnectionHandle * @see #ConnectionHolder(java.sql.Connection, boolean) */ public ConnectionHolder(Connection connection) { this.connectionHandle = new SimpleConnectionHandle(connection); }
/** * Override the existing Connection handle with the given Connection. * Reset the handle if given {@code null}. * <p>Used for releasing the Connection on suspend (with a {@code null} * argument) and setting a fresh Connection on resume. */ protected void setConnection(@Nullable Connection connection) { if (this.currentConnection != null) { if (this.connectionHandle != null) { this.connectionHandle.releaseConnection(this.currentConnection); } this.currentConnection = null; } if (connection != null) { this.connectionHandle = new SimpleConnectionHandle(connection); } else { this.connectionHandle = null; } }
/** * Create a new ConnectionHolder for the given JDBC Connection, * wrapping it with a {@link SimpleConnectionHandle}. * @param connection the JDBC Connection to hold * @param transactionActive whether the given Connection is involved * in an ongoing transaction * @see SimpleConnectionHandle */ public ConnectionHolder(Connection connection, boolean transactionActive) { this(connection); this.transactionActive = transactionActive; }
/** * Create a new ConnectionHolder for the given JDBC Connection, * wrapping it with a {@link SimpleConnectionHandle}, * assuming that there is no ongoing transaction. * @param connection the JDBC Connection to hold * @see SimpleConnectionHandle * @see #ConnectionHolder(java.sql.Connection, boolean) */ public ConnectionHolder(Connection connection) { this.connectionHandle = new SimpleConnectionHandle(connection); }
/** * This implementation returns null, to indicate that JDBC Connection * retrieval is not supported. * @param database JDO Database instance. * @param readOnly True if data access is read-only. * @return A ConnectionHandle instance */ public ConnectionHandle getJdbcConnection(Database database, boolean readOnly) throws PersistenceException { return new SimpleConnectionHandle (database.getJdbcConnection()); }
/** * Override the existing Connection handle with the given Connection. * Reset the handle if given {@code null}. * <p>Used for releasing the Connection on suspend (with a {@code null} * argument) and setting a fresh Connection on resume. */ protected void setConnection(Connection connection) { if (this.currentConnection != null) { this.connectionHandle.releaseConnection(this.currentConnection); this.currentConnection = null; } if (connection != null) { this.connectionHandle = new SimpleConnectionHandle(connection); } else { this.connectionHandle = null; } }