Author: dfabulich Date: Wed Feb 11 09:18:45 2009 New Revision: 743278 URL: http://svn.apache.org/viewvc?rev=743278&view=rev Log: Deprecating methods that will be eliminated in favor of varargs in java5 branch
Modified: commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java Modified: commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java URL: http://svn.apache.org/viewvc/commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java?rev=743278&r1=743277&r2=743278&view=diff ============================================================================== --- commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java (original) +++ commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java Wed Feb 11 09:18:45 2009 @@ -335,11 +335,12 @@ * @param rsh The handler that converts the results into an object. * @return The object returned by the handler. * @throws SQLException if a database access error occurs + * @deprecated Use {...@link #query(Connection,String,ResultSetHandler,Object[])} instead */ public Object query(Connection conn, String sql, Object param, ResultSetHandler rsh) throws SQLException { - return this.query(conn, sql, new Object[] { param }, rsh); + return this.query(conn, sql, rsh, new Object[] { param }); } /** @@ -352,9 +353,26 @@ * @param rsh The handler that converts the results into an object. * @return The object returned by the handler. * @throws SQLException if a database access error occurs + * @deprecated Use {...@link #query(Connection,String,ResultSetHandler,Object[])} instead */ public Object query(Connection conn, String sql, Object[] params, ResultSetHandler rsh) throws SQLException { + return query(conn, sql, rsh, params); + } + + /** + * Execute an SQL SELECT query with replacement parameters. The + * caller is responsible for closing the connection. + * + * @param conn The connection to execute the query in. + * @param sql The query to execute. + * @param rsh The handler that converts the results into an object. + * @param params The replacement parameters. + * @return The object returned by the handler. + * @throws SQLException if a database access error occurs + */ + public Object query(Connection conn, String sql, ResultSetHandler rsh, + Object[] params) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; @@ -393,7 +411,7 @@ public Object query(Connection conn, String sql, ResultSetHandler rsh) throws SQLException { - return this.query(conn, sql, (Object[]) null, rsh); + return this.query(conn, sql, rsh, (Object[]) null); } /** @@ -408,11 +426,12 @@ * * @return An object generated by the handler. * @throws SQLException if a database access error occurs + * @deprecated Use {...@link #query(String,ResultSetHandler,Object[])} instead */ public Object query(String sql, Object param, ResultSetHandler rsh) throws SQLException { - return this.query(sql, new Object[] { param }, rsh); + return this.query(sql, rsh, new Object[] { param }); } /** @@ -429,14 +448,33 @@ * * @return An object generated by the handler. * @throws SQLException if a database access error occurs + * @deprecated Use {...@link #query(String,ResultSetHandler,Object[])} instead */ public Object query(String sql, Object[] params, ResultSetHandler rsh) throws SQLException { + return query(sql, rsh, params); + } + + /** + * Executes the given SELECT SQL query and returns a result object. + * The <code>Connection</code> is retrieved from the + * <code>DataSource</code> set in the constructor. + * + * @param sql The SQL statement to execute. + * @param rsh The handler used to create the result object from + * the <code>ResultSet</code>. + * @param params Initialize the PreparedStatement's IN parameters with + * this array. + * @return An object generated by the handler. + * @throws SQLException if a database access error occurs + */ + public Object query(String sql, ResultSetHandler rsh, Object[] params) + throws SQLException { Connection conn = this.prepareConnection(); try { - return this.query(conn, sql, params, rsh); + return this.query(conn, sql, rsh, params); } finally { close(conn); } @@ -455,7 +493,7 @@ * @throws SQLException if a database access error occurs */ public Object query(String sql, ResultSetHandler rsh) throws SQLException { - return this.query(sql, (Object[]) null, rsh); + return this.query(sql, rsh, (Object[]) null); } /**