ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41836] New: - No warning from SQL task, but jdbc gets SQL State: 23000
Date Tue, 13 Mar 2007 23:16:55 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41836>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41836

           Summary: No warning from SQL task, but jdbc gets SQL State: 23000
           Product: Ant
           Version: 1.6.5
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: apache@digicoast.com
                CC: apache@digicoast.com


There is a specific warning that I was expecting after a flawed SQL statement 
was executed but Ant executes the statement and reports "1 of 1 SQL statements 
executed successfully".   

A java stub that tests the same query gets:
SQL Warning:
Column 'col1' in group statement is ambiguous
ANSI-92 SQL State: 23000
Vendor Error Code: 1052

This is with MySQL Server 5.0.22, with MySQL Connector/J v5.0.5.

$ msyql -uroot -p

mysql> create schema test;
mysql> create table test.x (id int);
mysql> create table test.y (id int, col1 varchar(10));
mysql> quit;

# Do not forget to set classpath to include mysql-connector jar 
# 

$ javac JDBCTestErr1052.java
$ java JDBCTestErr1052

query:select 'test' as col1 from test.x inner join test.y on (y.id = 1) group 
by col1

SQL Warning:
Column 'col1' in group statement is ambiguous
ANSI-92 SQL State: 23000
Vendor Error Code: 1052

$ cat JDBCTestErr1052.java
import java.sql.*;

public class JDBCTestErr1052 {
    private static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    private static final String JDBC_URL    = "jdbc:mysql://localhost/";
    private static final String JDBC_USER   = "root";
    private static final String JDBC_PASS   = "blah";

    private static final String query =
     "select 'test' as col1 from test.x inner join test.y on (y.id = 1) group 
by col1";

    public static void printWarnings(SQLWarning warn) {
      while (warn != null) {
        System.out.println("\nSQL Warning:");
        System.out.println(warn.getMessage(  ));
        System.out.println("ANSI-92 SQL State: " + warn.getSQLState(  ));
        System.out.println("Vendor Error Code: " + warn.getErrorCode(  ));
        warn = warn.getNextWarning(  );
      }
    }

    public static void main(String[] args) throws Throwable {
        System.out.println("query:"+query);

        Class.forName(JDBC_DRIVER).newInstance();
        Connection conn = 
DriverManager.getConnection(JDBC_URL,JDBC_USER,JDBC_PASS);

        try {
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(query);

            printWarnings(st.getWarnings());
            printWarnings(rs.getWarnings());

            rs.close();
            st.close();
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
    }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message