ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John H. Lee" <j...@c.kiracom.com>
Subject [PATCH] SQLExec.java NullPointerException
Date Wed, 26 Jul 2000 00:47:15 GMT
Fixes two silly errors:

    1. execute() created the Connection in a local variable,
       leaving the Connection used in other methods null.
    2. conn.setAutoCommit() was being called before conn
       was set.

-John




Index: SQLExec.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v

retrieving revision 1.3
diff -u -r1.3 SQLExec.java
--- SQLExec.java        2000/07/25 13:55:07     1.3
+++ SQLExec.java        2000/07/26 00:43:44
@@ -170,7 +170,6 @@
      * Load the sql file and then execute it
      */
     public void execute() throws BuildException {
-        Connection conn = null;

         sqlCommand = sqlCommand.trim();

@@ -200,10 +199,11 @@
         }

         try{
-            conn.setAutoCommit(autocommit);
-
             log("connecting to " + url, Project.MSG_VERBOSE );
             conn = DriverManager.getConnection(url, userId, password);
+
+            conn.setAutoCommit(autocommit);
+
             statement = conn.createStatement();

             if (sqlCommand.length() != 0) {


Mime
View raw message