/** * Executes the given SQL statement and signals the driver that the * auto-generated keys indicated in the given array should be made available * for retrieval. The driver will ignore the array if the SQL statement * is not an <code>INSERT</code> statement. * * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code> statement or an SQL statement that returns nothing * @param columnNames an array of the names of the columns that should be * returned from the inserted row * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, * or <code>DELETE</code> statements, or 0 for SQL statements * that return nothing * @exception SQLException if a database access error occurs * * @since 1.4 */ public int executeUpdate(String sql, String columnNames[]) throws SQLException { if (columnNames == null || columnNames.length == 0) return executeUpdate(sql); sql = addReturning(connection, sql, columnNames, true); wantsGeneratedKeysOnce = true; return executeUpdate(sql); }
/** * Retrieves any auto-generated keys created as a result of executing this * <code>Statement</code> object. If this <code>Statement</code> object did * not generate any keys, an empty <code>ResultSet</code> * object is returned. * * @return a <code>ResultSet</code> object containing the auto-generated key(s) * generated by the execution of this <code>Statement</code> object * @exception SQLException if a database access error occurs * @since 1.4 */ public ResultSet getGeneratedKeys() throws SQLException { checkClosed(); if (generatedKeys == null || generatedKeys.getResultSet() == null) return createDriverResultSet(new Field[0], new Vector()); return generatedKeys.getResultSet(); }
return execute(sql); sql = addReturning(connection, sql, new String[]{"*"}, false); wantsGeneratedKeysOnce = true; return execute(sql);
public void setObject(int parameterIndex, Object x) throws SQLException { if (x instanceof UUID && connection.haveMinimumServerVersion("8.3")) { setString(parameterIndex, x.toString(), Oid.UUID); } else { super.setObject(parameterIndex, x); } }
sql = AbstractJdbc3Statement.addReturning(this, sql, columnNames, true);
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException { // ignore scale for now registerOutParameter(parameterIndex, sqlType ); } }
/** * 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; }
/** * Executes the given SQL statement and signals the driver that the * auto-generated keys indicated in the given array should be made available * for retrieval. The driver will ignore the array if the SQL statement * is not an <code>INSERT</code> statement. * * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code> statement or an SQL statement that returns nothing, * such as an SQL DDL statement * @param columnIndexes an array of column indexes indicating the columns * that should be returned from the inserted row * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, * or <code>DELETE</code> statements, or 0 for SQL statements * that return nothing * @exception SQLException if a database access error occurs or the SQL * statement returns a <code>ResultSet</code> object * @since 1.4 */ public int executeUpdate(String sql, int columnIndexes[]) throws SQLException { if (columnIndexes == null || columnIndexes.length == 0) return executeUpdate(sql); throw new PSQLException(GT.tr("Returning autogenerated keys by column index is not supported."), PSQLState.NOT_IMPLEMENTED); }
return execute(sql);
public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException { if (targetSqlType == Types.OTHER && x instanceof UUID && connection.haveMinimumServerVersion("8.3")) { setString(parameterIndex, x.toString(), Oid.UUID); } else { super.setObject(parameterIndex, x, targetSqlType, scale); } } }
sql = AbstractJdbc3Statement.addReturning(this, sql, new String[]{"*"}, false);
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException { // ignore scale for now registerOutParameter(parameterIndex, sqlType ); } }
/** * 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; }
/** * Executes the given SQL statement and signals the driver that the * auto-generated keys indicated in the given array should be made available * for retrieval. The driver will ignore the array if the SQL statement * is not an <code>INSERT</code> statement. * * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code> statement or an SQL statement that returns nothing, * such as an SQL DDL statement * @param columnIndexes an array of column indexes indicating the columns * that should be returned from the inserted row * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, * or <code>DELETE</code> statements, or 0 for SQL statements * that return nothing * @exception SQLException if a database access error occurs or the SQL * statement returns a <code>ResultSet</code> object * @since 1.4 */ public int executeUpdate(String sql, int columnIndexes[]) throws SQLException { if (columnIndexes == null || columnIndexes.length == 0) return executeUpdate(sql); throw new PSQLException(GT.tr("Returning autogenerated keys by column index is not supported."), PSQLState.NOT_IMPLEMENTED); }
return execute(sql);
/** * Executes the given SQL statement and signals the driver with the * given flag about whether the * auto-generated keys produced by this <code>Statement</code> object * should be made available for retrieval. * * @param sql must be an SQL <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code> statement or an SQL statement that * returns nothing * @param autoGeneratedKeys a flag indicating whether auto-generated keys * should be made available for retrieval; * one of the following constants: * <code>Statement.RETURN_GENERATED_KEYS</code> * <code>Statement.NO_GENERATED_KEYS</code> * @return either the row count for <code>INSERT</code>, <code>UPDATE</code> * or <code>DELETE</code> statements, or <code>0</code> for SQL * statements that return nothing * @exception SQLException if a database access error occurs, the given * SQL statement returns a <code>ResultSet</code> object, or * the given constant is not one of those allowed * @since 1.4 */ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS) return executeUpdate(sql); sql = addReturning(connection, sql, new String[]{"*"}, false); wantsGeneratedKeysOnce = true; return executeUpdate(sql); }
return execute(sql); sql = addReturning(connection, sql, columnNames, true); wantsGeneratedKeysOnce = true; return execute(sql);
/** * Retrieves any auto-generated keys created as a result of executing this * <code>Statement</code> object. If this <code>Statement</code> object did * not generate any keys, an empty <code>ResultSet</code> * object is returned. * * @return a <code>ResultSet</code> object containing the auto-generated key(s) * generated by the execution of this <code>Statement</code> object * @exception SQLException if a database access error occurs * @since 1.4 */ public ResultSet getGeneratedKeys() throws SQLException { checkClosed(); if (generatedKeys == null || generatedKeys.getResultSet() == null) return createDriverResultSet(new Field[0], new Vector()); return generatedKeys.getResultSet(); }
public void setObject(int parameterIndex, Object x) throws SQLException { if (x instanceof UUID && connection.haveMinimumServerVersion("8.3")) { setString(parameterIndex, x.toString(), Oid.UUID); } else { super.setObject(parameterIndex, x); } }
sql = AbstractJdbc3Statement.addReturning(this, sql, new String[]{"*"}, false);