public void clearParameters() throws SQLException { preparedParameters.clear(); }
public void addBatch() throws SQLException { checkClosed(); if (batchStatements == null) { batchStatements = new ArrayList<Query>(); batchParameters = new ArrayList<ParameterList>(); } // we need to create copies of our parameters, otherwise the values can be changed batchParameters.add(preparedParameters.copy()); Query query = preparedQuery.query; if (!(query instanceof BatchedQuery) || batchStatements.isEmpty()) { batchStatements.add(query); } }
PgCallableStatement(PgConnection connection, String sql, int rsType, int rsConcurrency, int rsHoldability) throws SQLException { super(connection, connection.borrowCallableQuery(sql), rsType, rsConcurrency, rsHoldability); this.isFunction = preparedQuery.isFunction; if (this.isFunction) { int inParamCount = this.preparedParameters.getInParameterCount() + 1; this.testReturn = new int[inParamCount]; this.functionReturnType = new int[inParamCount]; } }
int outParameterCount = preparedParameters.getOutParameterCount() ; callResult = new Object[preparedParameters.getParameterCount()+1];
protected void setString(int parameterIndex, String x, int oid) throws SQLException { // if the passed string is null, then set this column to null checkClosed(); if (x == null) { preparedParameters.setNull(parameterIndex, oid); } else { bindString(parameterIndex, x, oid); } }
public void setBinaryStream(int parameterIndex, InputStream value) throws SQLException { preparedParameters.setBytea(parameterIndex, value); }
public ParameterMetaData getParameterMetaData() throws SQLException { int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_DESCRIBE_ONLY | QueryExecutor.QUERY_SUPPRESS_BEGIN; StatementResultHandler handler = new StatementResultHandler(); connection.getQueryExecutor().execute(preparedQuery.query, preparedParameters, handler, 0, 0, flags); int[] oids = preparedParameters.getTypeOIDs(); if (oids != null) { return createParameterMetaData(connection, oids); } return null; }
/** * Note if s is a String it should be escaped by the caller to avoid SQL injection attacks. It is * not done here for efficiency reasons as most calls to this method do not require escaping as * the source of the string is known safe (i.e. {@code Integer.toString()}) * * @param paramIndex parameter index * @param s value (the value should already be escaped) * @param oid type oid * @throws SQLException if something goes wrong */ protected void bindLiteral(int paramIndex, String s, int oid) throws SQLException { preparedParameters.setLiteralParameter(paramIndex, s, oid); }
preparedParameters.registerOutParameter( parameterIndex, sqlType );
int outParameterCount = preparedParameters.getOutParameterCount(); callResult = new Object[preparedParameters.getParameterCount() + 1];
protected void setString(int parameterIndex, String x, int oid) throws SQLException { // if the passed string is null, then set this column to null checkClosed(); if (x == null) { if ( adjustIndex ) parameterIndex--; preparedParameters.setNull( parameterIndex, oid); } else bindString(parameterIndex, x, oid); }
public void setBytes(int parameterIndex, byte[] x) throws SQLException { checkClosed(); if (null == x) { setNull(parameterIndex, Types.VARBINARY); return; } // Version 7.2 supports the bytea datatype for byte arrays byte[] copy = new byte[x.length]; System.arraycopy(x, 0, copy, 0, x.length); preparedParameters.setBytea(parameterIndex, copy, 0, x.length); }
/** * Retrieves the number, types and properties of this * <code>PreparedStatement</code> object's parameters. * * @return a <code>ParameterMetaData</code> object that contains information * about the number, types and properties of this * <code>PreparedStatement</code> object's parameters * @exception SQLException if a database access error occurs * @see ParameterMetaData * @since 1.4 */ public ParameterMetaData getParameterMetaData() throws SQLException { int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_DESCRIBE_ONLY | QueryExecutor.QUERY_SUPPRESS_BEGIN; StatementResultHandler handler = new StatementResultHandler(); connection.getQueryExecutor().execute(preparedQuery, preparedParameters, handler, 0, 0, flags); int oids[] = preparedParameters.getTypeOIDs(); if (oids != null) return createParameterMetaData(connection, oids); return null; }
protected void bindLiteral(int paramIndex, String s, int oid) throws SQLException { if(adjustIndex) paramIndex--; preparedParameters.setLiteralParameter(paramIndex, s, oid); }
preparedParameters.registerOutParameter(parameterIndex, sqlType);
int outParameterCount = preparedParameters.getOutParameterCount() ; callResult = new Object[preparedParameters.getParameterCount()+1];
public void setNull(int parameterIndex, int targetSqlType) throws SQLException { checkClosed(); int oid; switch (targetSqlType) { case Types.SQLXML: oid = Oid.XML; break; default: super.setNull(parameterIndex, targetSqlType); return; } if (adjustIndex) parameterIndex--; preparedParameters.setNull(parameterIndex, oid); }