commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r348539 - /jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/QueryRunner.java
Date Wed, 23 Nov 2005 20:09:27 GMT
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


Mime
View raw message