/** * Creates a savepoint with the given name in the current transaction * and returns the new <code>Savepoint</code> object that represents it. * * @param name a <code>String</code> containing the name of the savepoint * @return the new <code>Savepoint</code> object * @exception SQLException if a database access error occurs * or this <code>Connection</code> object is currently in * auto-commit mode * @see Savepoint * @since 1.4 */ public Savepoint setSavepoint(String name) throws SQLException { checkClosed(); if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); if (getAutoCommit()) throw new PSQLException(GT.tr("Cannot establish a savepoint in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); PSQLSavepoint savepoint = new PSQLSavepoint(name); // Note we can't use execSQLUpdate because we don't want // to suppress BEGIN. Statement stmt = createStatement(); stmt.executeUpdate("SAVEPOINT " + savepoint.getPGName()); stmt.close(); return savepoint; }
/** * Undoes all changes made after the given <code>Savepoint</code> object * was set. * <P> * This method should be used only when auto-commit has been disabled. * * @param savepoint the <code>Savepoint</code> object to roll back to * @exception SQLException if a database access error occurs, * the <code>Savepoint</code> object is no longer valid, * or this <code>Connection</code> object is currently in * auto-commit mode * @see Savepoint * @see #rollback * @since 1.4 */ public void rollback(Savepoint savepoint) throws SQLException { checkClosed(); if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); PSQLSavepoint pgSavepoint = (PSQLSavepoint)savepoint; execSQLUpdate("ROLLBACK TO SAVEPOINT " + pgSavepoint.getPGName()); }
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { checkClosed(); return prepareCall(sql, resultSetType, resultSetConcurrency, getHoldability()); }
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { checkClosed(); return prepareStatement(sql, resultSetType, resultSetConcurrency, getHoldability()); }
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { checkClosed(); return createStatement(resultSetType, resultSetConcurrency, getHoldability()); }
/** * Creates a savepoint with the given name in the current transaction * and returns the new <code>Savepoint</code> object that represents it. * * @param name a <code>String</code> containing the name of the savepoint * @return the new <code>Savepoint</code> object * @exception SQLException if a database access error occurs * or this <code>Connection</code> object is currently in * auto-commit mode * @see Savepoint * @since 1.4 */ public Savepoint setSavepoint(String name) throws SQLException { if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); if (getAutoCommit()) throw new PSQLException(GT.tr("Cannot establish a savepoint in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); PSQLSavepoint savepoint = new PSQLSavepoint(name); // Note we can't use execSQLUpdate because we don't want // to suppress BEGIN. Statement stmt = createStatement(); stmt.executeUpdate("SAVEPOINT " + savepoint.getPGName()); stmt.close(); return savepoint; }
throws SQLException checkClosed(); if (autoGeneratedKeys != Statement.NO_GENERATED_KEYS) sql = AbstractJdbc3Statement.addReturning(this, sql, new String[]{"*"}, false); PreparedStatement ps = prepareStatement(sql);
/** * Undoes all changes made after the given <code>Savepoint</code> object * was set. * <P> * This method should be used only when auto-commit has been disabled. * * @param savepoint the <code>Savepoint</code> object to roll back to * @exception SQLException if a database access error occurs, * the <code>Savepoint</code> object is no longer valid, * or this <code>Connection</code> object is currently in * auto-commit mode * @see Savepoint * @see #rollback * @since 1.4 */ public void rollback(Savepoint savepoint) throws SQLException { if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); PSQLSavepoint pgSavepoint = (PSQLSavepoint)savepoint; execSQLUpdate("ROLLBACK TO SAVEPOINT " + pgSavepoint.getPGName()); }
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { return createStatement(resultSetType, resultSetConcurrency, getHoldability()); }
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { return prepareCall(sql, resultSetType, resultSetConcurrency, getHoldability()); }
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { return prepareStatement(sql, resultSetType, resultSetConcurrency, getHoldability()); }
sql = AbstractJdbc3Statement.addReturning(this, sql, columnNames, true); PreparedStatement ps = prepareStatement(sql);
/** * Retrieves the current holdability of <code>ResultSet</code> objects * created using this <code>Connection</code> object. * * @return the holdability, one of * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> * @throws SQLException if a database access occurs * @see #setHoldability * @see ResultSet * @since 1.4 */ public int getHoldability() throws SQLException { checkClosed(); return rsHoldability; }
/** * Creates an unnamed savepoint in the current transaction and * returns the new <code>Savepoint</code> object that represents it. * * @return the new <code>Savepoint</code> object * @exception SQLException if a database access error occurs * or this <code>Connection</code> object is currently in * auto-commit mode * @see Savepoint * @since 1.4 */ public Savepoint setSavepoint() throws SQLException { if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); if (getAutoCommit()) throw new PSQLException(GT.tr("Cannot establish a savepoint in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); PSQLSavepoint savepoint = new PSQLSavepoint(savepointId++); // Note we can't use execSQLUpdate because we don't want // to suppress BEGIN. Statement stmt = createStatement(); stmt.executeUpdate("SAVEPOINT " + savepoint.getPGName()); stmt.close(); return savepoint; }
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { checkClosed(); return prepareStatement(sql, resultSetType, resultSetConcurrency, getHoldability()); }
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { checkClosed(); return createStatement(resultSetType, resultSetConcurrency, getHoldability()); }
return prepareStatement(sql); checkClosed(); throw new PSQLException(GT.tr("Returning autogenerated keys is not supported."), PSQLState.NOT_IMPLEMENTED);
/** * Removes the given <code>Savepoint</code> object from the current * transaction. Any reference to the savepoint after it have been removed * will cause an <code>SQLException</code> to be thrown. * * @param savepoint the <code>Savepoint</code> object to be removed * @exception SQLException if a database access error occurs or * the given <code>Savepoint</code> object is not a valid * savepoint in the current transaction * @since 1.4 */ public void releaseSavepoint(Savepoint savepoint) throws SQLException { if (!haveMinimumServerVersion("8.0")) throw new PSQLException(GT.tr("Server versions prior to 8.0 do not support savepoints."), PSQLState.NOT_IMPLEMENTED); PSQLSavepoint pgSavepoint = (PSQLSavepoint)savepoint; execSQLUpdate("RELEASE SAVEPOINT " + pgSavepoint.getPGName()); pgSavepoint.invalidate(); }
sql = AbstractJdbc3Statement.addReturning(this, sql, new String[]{"*"}, false); PreparedStatement ps = prepareStatement(sql);