Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6280559

JDBC4: Not able to query data using @Query annotation.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 6
    • core-libs
    • b47
    • generic
    • generic
    • Verified

      JDK : 1.6.0-b39
      DB: ORCL.

      =============
      Base on the dev spec and java doc EOD, a simple @Query annotation should query data from the database, but it having a "java.lang.reflect.UndeclaredThrowableException"


      Java source
      ===========
      import java.io.File;
      import java.util.*;
      import java.sql.*;
      import javax.sql.*;
      import com.sun.sql.*;

      class t {
        int id;
        String fname;
      }

      interface myname extends BaseQuery {
        @Query(sql="select * from t")
        DataSet<t> getAll();
      }

      public class jdbc4_try
      {
      public static void main(String [] args) {

       Connection con = null;
       Statement s;
       String driverClassName = "com.inet.ora.OraDriver";
       try {
        Class.forName(driverClassName);
        con = DriverManager.getConnection("jdbc:inetora:[your DB]:1521:ORCL","UID","PWD");

             s = con.createStatement();
             try {
             s.executeUpdate("DROP TABLE t"); }catch (Exception ex) {
               System.out.println("e1 "+ ex); }
             s.executeUpdate("CREATE TABLE t (age INT, name VARCHAR2(50))");
             s.executeUpdate("INSERT INTO t values(10, 'custom1')");
             s.executeUpdate("INSERT INTO t values(22, 'custom2')");
             s.executeUpdate("INSERT INTO t values(33, 'testName')");

             ResultSet result = s.executeQuery("SELECT * from t");
             result.next();
             System.out.println("custome is " + result.getString("name"));
             System.out.println("age is " + result.getString("age"));

             myname myQImpl = QueryObjectFactory.createDefaultQueryObject(myname.class,con);

             DataSet<t> newCust = myQImpl.getAll();
             for (t c: newCust){
                System.out.println("id " + c.id);
                System.out.println("name " + c.fname);
             }
       }catch(Exception ex) { System.out.println("2 exception." + ex); ex.printStackTrace(); }

      }
      }


      ERROR:
      ======
      custome is custom1
      age is 10
      2 exception.java.lang.reflect.UndeclaredThrowableException
      java.lang.reflect.UndeclaredThrowableException
              at $Proxy0.getAll(Unknown Source)
              at jdbc4_try.main(jdbc4_try.java:55)
      Caused by: java.sql.SQLException: [OraDriver] Parameter is null.
              at com.inet.ora.OraDriver.a(Unknown Source)
              at com.inet.ora.k.a(Unknown Source)
              at com.inet.ora.k.findColumn(Unknown Source)
              at com.sun.sql.QueryObjectGeneratorImpl.getQueryImpl(QueryObjectGeneratorImpl.java:371)
              at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:119)
              ... 2 more

      ###@###.### 2005-06-04 02:09:26 GMT

            skaushiksunw Shreyas Kaushik (Inactive)
            tacheung Tak Wing Cheung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: