ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs SQLExec.java
Date Wed, 26 Jul 2000 09:54:54 GMT
bodewig     00/07/26 02:54:53

  Modified:    src/main/org/apache/tools/ant/taskdefs SQLExec.java
  Log:
  The instance variable conn was shadowed by a local variable in
  execute, failed to remove ; from statement with trailing white space,
  made class easier to extend for specialized tasks like <plsql>.
  Submitted by:	John H. Lee <jlee@c.kiracom.com>,
                  Curt Hagenlocher <curt@hagenlocher.org>,
                  Jose  Alberto Fernandez <JFernandez@viquity.com>
  
  Revision  Changes    Path
  1.4       +9 -8      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  
  Index: SQLExec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SQLExec.java	2000/07/25 13:55:07	1.3
  +++ SQLExec.java	2000/07/26 09:54:53	1.4
  @@ -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) {
  @@ -248,7 +248,7 @@
           log("SQL statements executed successfully", Project.MSG_VERBOSE);
       }
   
  -    private void runStatements(Reader reader) throws SQLException, IOException {
  +    protected void runStatements(Reader reader) throws SQLException, IOException {
           String sql = "";
           String line = "";
    
  @@ -260,7 +260,8 @@
                   if (line.trim().startsWith("--")) continue;
         
                   sql += " " + line;
  -                if (sql.trim().endsWith(";")){
  +                sql = sql.trim();
  +                if (sql.endsWith(";")){
                       log("SQL: " + sql, Project.MSG_VERBOSE);
                       execSQL(sql.substring(0, sql.length()-1));
                       sql = "";
  @@ -268,7 +269,7 @@
               }
    
    	    // Catch any statements not followed by ;
  - 	    if(!sql.trim().equals("")){
  + 	    if(!sql.equals("")){
    	    	execSQL(sql);
    	    }
    	}catch(SQLException e){
  @@ -281,7 +282,7 @@
       /**
        * Exec the sql statement.
        */
  -    private void execSQL(String sql) throws SQLException{
  +    protected void execSQL(String sql) throws SQLException{
           if (!statement.execute(sql)) {
               log(statement.getUpdateCount()+" rows affected", 
                   Project.MSG_VERBOSE);
  @@ -289,7 +290,7 @@
   
           SQLWarning warning = conn.getWarnings();
           while(warning!=null){
  -            log(warning + " sql warnging", Project.MSG_VERBOSE);
  +            log(warning + " sql warning", Project.MSG_VERBOSE);
               warning=warning.getNextWarning();
           }
           conn.clearWarnings();
  
  
  

Mime
View raw message