@Override public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) { try { ResultSet rs = PgStatement.this.createResultSet(fromQuery, fields, tuples, cursor); append(new ResultWrapper(rs)); } catch (SQLException e) { handleError(e); } }
@Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { checkClosed(); PSQLSavepoint pgSavepoint = (PSQLSavepoint) savepoint; execSQLUpdate("RELEASE SAVEPOINT " + pgSavepoint.getPGName()); pgSavepoint.invalidate(); }
public synchronized void updateNull(int columnIndex) throws SQLException { checkColumnIndex(columnIndex); String columnTypeName = getPGType(columnIndex); updateValue(columnIndex, new NullObject(columnTypeName)); }
public ResultSet createResultSet(Query originalQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) throws SQLException { PgResultSet newResult = new PgResultSet(originalQuery, this, fields, tuples, cursor, getMaxRows(), getMaxFieldSize(), getResultSetType(), getResultSetConcurrency(), getResultSetHoldability()); newResult.setFetchSize(getFetchSize()); newResult.setFetchDirection(getFetchDirection()); return newResult; }
PgStatement(PgConnection c, int rsType, int rsConcurrency, int rsHoldability) throws SQLException { this.connection = c; forceBinaryTransfers |= c.getForceBinary(); resultsettype = rsType; concurrency = rsConcurrency; setFetchSize(c.getDefaultFetchSize()); setPrepareThreshold(c.getPrepareThreshold()); this.rsHoldability = rsHoldability; }
public boolean executeWithFlags(CachedQuery simpleQuery, int flags) throws SQLException { checkClosed(); if (connection.getPreferQueryMode().compareTo(PreferQueryMode.EXTENDED) < 0) { flags |= QueryExecutor.QUERY_EXECUTE_AS_SIMPLE; } execute(simpleQuery, null, flags); synchronized (this) { checkClosed(); return (result != null && result.getResultSet() != null); } }
@Override public void rollback(Savepoint savepoint) throws SQLException { checkClosed(); PSQLSavepoint pgSavepoint = (PSQLSavepoint) savepoint; execSQLUpdate("ROLLBACK TO SAVEPOINT " + pgSavepoint.getPGName()); }
public int getUpdateCount() throws SQLException { synchronized (this) { checkClosed(); if (result == null || result.getResultSet() != null) { return -1; } return result.getUpdateCount(); } }
public java.sql.ResultSet getResultSet() throws SQLException { synchronized (this) { checkClosed(); if (result == null) { return null; } return result.getResultSet(); } }
@Override public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { checkClosed(); return new PgStatement(this, resultSetType, resultSetConcurrency, resultSetHoldability); }
@Override public DatabaseMetaData getMetaData() throws SQLException { checkClosed(); if (metadata == null) { metadata = new PgDatabaseMetaData(this); } return metadata; }
public SQLWarning getWarnings() throws SQLException { checkClosed(); //copy reference to avoid NPE from concurrent modification of this.warnings final PSQLWarningWrapper warnWrap = this.warnings; return warnWrap != null ? warnWrap.getFirstWarning() : null; }
@Override public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { checkClosed(); return new PgCallableStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability); }
public long getLastOID() throws SQLException { synchronized (this) { checkClosed(); if (result == null) { return 0; } return result.getInsertOID(); } }
public int executeUpdate() throws SQLException { if (isFunction) { executeWithFlags(0); return 0; } return super.executeUpdate(); }
@Override public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { checkClosed(); return new PgPreparedStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability); }
@Override public void handleCommandStatus(String status, int updateCount, long insertOID) { append(new ResultWrapper(updateCount, insertOID)); }
public SQLXML getSQLXML(int parameterIndex) throws SQLException { checkClosed(); checkIndex(parameterIndex, Types.SQLXML, "SQLXML"); return (SQLXML) callResult[parameterIndex - 1]; }
/** * power to pow translation * * @param buf The buffer to append into * @param parsedArgs arguments * @throws SQLException if something wrong happens */ public static void sqlpower(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException { twoArgumentsFunctionCall(buf, "pow(", "power", parsedArgs); }
/** * second translation * * @param buf The buffer to append into * @param parsedArgs arguments * @throws SQLException if something wrong happens */ public static void sqlsecond(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException { singleArgumentFunctionCall(buf, "extract(second from ", "second", parsedArgs); }