You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2005/11/23 21:09:27 UTC

svn commit: r348539 - /jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java

Author: bayard
Date: Wed Nov 23 12:09:26 2005
New Revision: 348539

URL: http://svn.apache.org/viewcvs?rev=348539&view=rev
Log:
It can be confusing to get a NullPointerException when you forget to set the DataSource or include the Connection parameter, so I've added a dedicated exception for this event

Modified:
    jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java

Modified: jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java?rev=348539&r1=348538&r2=348539&view=diff
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java (original)
+++ jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java Wed Nov 23 12:09:26 2005
@@ -186,6 +186,9 @@
      * @since DbUtils 1.1
      */
     protected Connection prepareConnection() throws SQLException {
+        if(this.getDataSource() == null) {
+            throw new SQLException("QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in");
+        }
         return this.getDataSource().getConnection();
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org