public CopyIn copyIn(String sql) throws SQLException { CopyOperation op = queryExecutor.startCopy(sql, connection.getAutoCommit()); if (op == null || op instanceof CopyIn) { return (CopyIn) op; } else { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyIn but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE); } }
public CopyDual copyDual(String sql) throws SQLException { CopyOperation op = queryExecutor.startCopy(sql, connection.getAutoCommit()); if (op == null || op instanceof CopyDual) { return (CopyDual) op; } else { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyDual but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE); } }
public CopyIn copyIn(String sql) throws SQLException { CopyOperation op = null; try { op = queryExecutor.startCopy(sql, connection.getAutoCommit()); return (CopyIn) op; } catch(ClassCastException cce) { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyIn but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE, cce); } }
public CopyOut copyOut(String sql) throws SQLException { CopyOperation op = queryExecutor.startCopy(sql, connection.getAutoCommit()); if (op == null || op instanceof CopyOut) { return (CopyOut) op; } else { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyOut but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE); } }
public CopyOut copyOut(String sql) throws SQLException { CopyOperation op = null; try { op = queryExecutor.startCopy(sql, connection.getAutoCommit()); return (CopyOut) op; } catch(ClassCastException cce) { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyOut but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE, cce); } }
/** * This opens an existing large object, based on its OID * * @param oid of large object * @param mode mode of open * @return LargeObject instance providing access to the object * @exception SQLException on error */ public LargeObject open(long oid, int mode) throws SQLException { if (conn.getAutoCommit()) throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); return new LargeObject(fp, oid, mode); }
/** * Send a function call to the PostgreSQL backend. * * @param fnId Function id * @param args FastpathArguments to pass to fastpath * @return null if no data, byte[] otherwise * @throws SQLException if a database-access error occurs. */ public byte[] fastpath(int fnId, FastpathArg[] args) throws SQLException { // Turn fastpath array into a parameter list. ParameterList params = executor.createFastpathParameters(args.length); for (int i = 0; i < args.length; ++i) { args[i].populateParameter(params, i + 1); } // Run it. return executor.fastpathCall(fnId, params, connection.getAutoCommit()); }
/** * This opens an existing large object, based on its OID. * * @param oid of large object * @param mode mode of open * @param commitOnClose commit the transaction when this LOB will be closed * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(long oid, int mode, boolean commitOnClose) throws SQLException { if (conn.getAutoCommit()) { throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); } return new LargeObject(fp, oid, mode, conn, commitOnClose); }
/** * Send a function call to the PostgreSQL backend * * @param fnId Function id * @param resultType True if the result is an integer, false for other results * @param args FastpathArguments to pass to fastpath * @return null if no data, Integer if an integer result, or byte[] otherwise * @exception SQLException if a database-access error occurs. */ public Object fastpath(int fnId, boolean resultType, FastpathArg[] args) throws SQLException { // Turn fastpath array into a parameter list. ParameterList params = executor.createFastpathParameters(args.length); for (int i = 0; i < args.length; ++i) { args[i].populateParameter(params, i + 1); } // Run it. byte[] returnValue = executor.fastpathCall(fnId, params, connection.getAutoCommit()); // Interpret results. if (!resultType || returnValue == null) return returnValue; if (returnValue.length != 4) throw new PSQLException(GT.tr("Fastpath call {0} - No result was returned and we expected an integer.", new Integer(fnId)), PSQLState.NO_DATA); return new Integer((returnValue[3] & 255) | ((returnValue[2] & 255) << 8) | ((returnValue[1] & 255) << 16) | ((returnValue[0] & 255) << 24)); }
/** * This creates a large object, returning its OID. * * @param mode a bitmask describing different attributes of the new object * @return oid of new object * @throws SQLException on error */ public long createLO(int mode) throws SQLException { if (conn.getAutoCommit()) { throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); } FastpathArg[] args = new FastpathArg[1]; args[0] = new FastpathArg(mode); return fp.getOID("lo_creat", args); }
flags |= QueryExecutor.QUERY_ONESHOT; if (connection.getAutoCommit()) flags |= QueryExecutor.QUERY_SUPPRESS_BEGIN;
/** * This creates a large object, returning its OID * * @param mode a bitmask describing different attributes of the new object * @return oid of new object * @exception SQLException on error */ public long createLO(int mode) throws SQLException { if (conn.getAutoCommit()) throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); FastpathArg args[] = new FastpathArg[1]; args[0] = new FastpathArg(mode); return fp.getOID("lo_creat", args); }
localAutoCommitMode = conn.getAutoCommit(); conn.setAutoCommit(true); Statement stmt = conn.createStatement();
if (fetchSize > 0 && !wantsScrollableResultSet() && !connection.getAutoCommit() && !wantsHoldableResultSet()) flags |= QueryExecutor.QUERY_FORWARD_CURSOR; if (connection.getAutoCommit()) flags |= QueryExecutor.QUERY_SUPPRESS_BEGIN;
localAutoCommitMode = conn.getAutoCommit(); conn.setAutoCommit(true); Statement stmt = conn.createStatement();
if (connection.getAutoCommit()) { flags |= QueryExecutor.QUERY_SUPPRESS_BEGIN;
if (fetchSize > 0 && !wantsScrollableResultSet() && !connection.getAutoCommit() && !wantsHoldableResultSet()) { flags |= QueryExecutor.QUERY_FORWARD_CURSOR; if (connection.getAutoCommit()) { flags |= QueryExecutor.QUERY_SUPPRESS_BEGIN;
localAutoCommitMode = conn.getAutoCommit(); conn.setAutoCommit(false); } catch (SQLException ex) {
localAutoCommitMode = conn.getAutoCommit(); conn.setAutoCommit(false);
public CopyOut copyOut(String sql) throws SQLException { CopyOperation op = null; try { op = queryExecutor.startCopy(sql, connection.getAutoCommit()); return (CopyOut) op; } catch(ClassCastException cce) { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyOut but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE, cce); } }