Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 42022 invoked from network); 19 Jul 2004 01:41:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Jul 2004 01:41:30 -0000 Received: (qmail 66127 invoked by uid 500); 19 Jul 2004 01:41:28 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 66059 invoked by uid 500); 19 Jul 2004 01:41:27 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 66045 invoked by uid 500); 19 Jul 2004 01:41:27 -0000 Received: (qmail 66041 invoked by uid 99); 19 Jul 2004 01:41:27 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sun, 18 Jul 2004 18:41:27 -0700 Received: (qmail 42011 invoked by uid 1581); 19 Jul 2004 01:41:26 -0000 Date: 19 Jul 2004 01:41:26 -0000 Message-ID: <20040719014126.42010.qmail@minotaur.apache.org> From: dgraham@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/dbutils/xdocs changes.xml X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N dgraham 2004/07/18 18:41:26 Modified: dbutils/src/java/org/apache/commons/dbutils QueryRunner.java dbutils/xdocs changes.xml Log: Added QueryRunner.prepareConnection(). PR: 30032 Revision Changes Path 1.12 +35 -20 jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java Index: QueryRunner.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- QueryRunner.java 6 Jun 2004 14:35:39 -0000 1.11 +++ QueryRunner.java 19 Jul 2004 01:41:26 -0000 1.12 @@ -107,7 +107,7 @@ * @since DbUtils 1.1 */ public int[] batch(String sql, Object[][] params) throws SQLException { - Connection conn = this.ds.getConnection(); + Connection conn = this.prepareConnection(); try { return this.batch(conn, sql, params); @@ -166,24 +166,40 @@ return conn.prepareStatement(sql); } + + /** + * Factory method that creates and initializes a + * Connection object. QueryRunner methods + * always call this method to retrieve connections from its DataSource. + * Subclasses can override this method to provide + * special Connection configuration if needed. This + * implementation simply calls ds.getConnection(). + * + * @return An initialized Connection. + * @throws SQLException + * @since DbUtils 1.1 + */ + protected Connection prepareConnection() throws SQLException { + return this.ds.getConnection(); + } /** - * Execute an SQL SELECT query with a single replacement parameter. The + * Execute an SQL SELECT query with a single replacement parameter. The * caller is responsible for closing the connection. * - * @param conn The connection to execute the query in. - * @param sql The query to execute. - * @param param The replacement parameter. - * @param rsh The handler that converts the results into an object. + * @param conn + * The connection to execute the query in. + * @param sql + * The query to execute. + * @param param + * The replacement parameter. + * @param rsh + * The handler that converts the results into an object. * @return The object returned by the handler. * @throws SQLException */ - public Object query( - Connection conn, - String sql, - Object param, - ResultSetHandler rsh) - throws SQLException { + public Object query(Connection conn, String sql, Object param, + ResultSetHandler rsh) throws SQLException { return this.query(conn, sql, new Object[] { param }, rsh); } @@ -199,12 +215,8 @@ * @return The object returned by the handler. * @throws SQLException */ - public Object query( - Connection conn, - String sql, - Object[] params, - ResultSetHandler rsh) - throws SQLException { + public Object query(Connection conn, String sql, Object[] params, + ResultSetHandler rsh) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; @@ -285,7 +297,7 @@ public Object query(String sql, Object[] params, ResultSetHandler rsh) throws SQLException { - Connection conn = this.ds.getConnection(); + Connection conn = this.prepareConnection(); try { return this.query(conn, sql, params, rsh); @@ -461,7 +473,7 @@ * @return The number of rows updated. */ public int update(String sql, Object[] params) throws SQLException { - Connection conn = this.ds.getConnection(); + Connection conn = this.prepareConnection(); try { return this.update(conn, sql, params); @@ -499,6 +511,7 @@ * Close a Connection. This implementation avoids closing if * null and does not suppress any exceptions. Subclasses * can override to provide special handling like logging. + * @throws SQLException * @since DbUtils 1.1 */ protected void close(Connection conn) throws SQLException { @@ -509,6 +522,7 @@ * Close a Statement. This implementation avoids closing if * null and does not suppress any exceptions. Subclasses * can override to provide special handling like logging. + * @throws SQLException * @since DbUtils 1.1 */ protected void close(Statement stmt) throws SQLException { @@ -519,6 +533,7 @@ * Close a ResultSet. This implementation avoids closing if * null and does not suppress any exceptions. Subclasses * can override to provide special handling like logging. + * @throws SQLException * @since DbUtils 1.1 */ protected void close(ResultSet rs) throws SQLException { 1.2 +6 -0 jakarta-commons/dbutils/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/jakarta-commons/dbutils/xdocs/changes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- changes.xml 3 Apr 2004 05:19:13 -0000 1.1 +++ changes.xml 19 Jul 2004 01:41:26 -0000 1.2 @@ -40,6 +40,12 @@ + Added a protected QueryRunner.prepareConnection() method to + allow subclasses to customize the Connections retrieved from + the DataSource before they're used. + PR# 30032 + + Refactored bean handling from BasicRowProcessor into new BeanProcessor class. This also fixes the common problem with Oracle NUMERIC fields not being set into bean properties. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org