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

@Update parameterized sql annotation not behaving as expected with sql=insert is used.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b47
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      JDK : 1.6.0-b43/jdbc4.jar 7/19
      Testsuite : jdbc
      Platform[s] :
      switch/Mode :
      DataBase : Orcal
      DataBase Driver: inetora
      Failing Test : Planning to be into
          java_sql_eod/update/Update003_SQL_004

      Description:
      ===========
        When try to use perameter marker in the sql=insert statement, it will throws an SQLException.

      Sampe test:
      =============
      import java.sql.*;
      import java.util.*;
      import javax.sql.*;
      import com.sun.sql.*;

      interface myname extends BaseQuery {
          @Update(sql="update t set id={age} where fname={name}")
          int UpdateOne(int age, String name ) throws SQLException;
          
          @Update(sql="insert into t values({age},{name})")
          int InsertOne(int age, String name ) throws SQLException;
           
          @Query(sql="SELECT * from t")
          DataSet<table> getAll() throws SQLException;
      }

      public class EOD_update {
          public static void main(String [] args) {
              int returnRows = 0;
              Connection con = null;
              Statement s;
              String driverClassName = "com.inet.ora.OraDriver";
              try {
                  Class.forName(driverClassName);
           con=DriverManager.getConnection("jdbc:inetora:[YOUR DB]:ORCL",[USER],[USERID]);
                  s = con.createStatement();
                  try {
                      s.executeUpdate("DROP TABLE t");
                  }catch (SQLException ex) {
                      System.out.println("1st - Exception caught :" + ex.getMessage());
                  }
                  s.executeUpdate("CREATE TABLE t (id INT, fname VARCHAR2(32))");
                  System.out.println("upated is " + s.getUpdateCount());
                  s.executeUpdate("INSERT INTO t values(10, 'custom1')");
                  System.out.println("upated is " + s.getUpdateCount());
                  s.executeUpdate("INSERT INTO t values(22, 'custom2')");
                  System.out.println("upated is " + s.getUpdateCount());
                  s.executeUpdate("INSERT INTO t values(33, 'testName')");
                  System.out.println("upated is " + s.getUpdateCount());
                  
                  ResultSet result = s.executeQuery("SELECT * from t");
             result.next();
             System.out.println("custome is " + result.getString("fname"));
             System.out.println("age is " + result.getString("id"));
             result.next();
             System.out.println("custome is " + result.getString("fname"));
             System.out.println("age is " + result.getString("id"));
                  
              try{
                  myname myQImpl=QueryObjectFactory.createDefaultQueryObject(myname.class,con);

                returnRows = myQImpl.InsertOne(999,"newName");
                DataSet<table> newCust = myQImpl.getAll();
                for (table c: newCust){
                    System.out.println("id =" + c.id+", name =" + c.fname);
                }
              }catch (SQLException SQLex) {
                  SQLex.printStackTrace();
              }
              }catch(Exception ex) {
                  System.out.println("Exception caught :" + ex.getMessage());
                  ex.printStackTrace();
              }
          }
      }

      -----------
      public class table {
        String fname;
        int id;
      }


      How to reproduce:
      ====================
      Change the [YOUR DB], [USER], [USERID] from the sample java file above.
      JDBC4=/net/cady/export/sqa/tcheung/jdbc/tiger_on_redcvs/jdbc4.0/build/jdbc4.jar
      javac EOD_update.java
      java -Xbootclasspath/p:$JDBC4 EOD_update

      Test output:
      =============
      upated is 0
      upated is 1
      upated is 1
      upated is 1
      custome is custom1
      age is 10
      custome is custom2
      age is 22
      java.sql.SQLException: There is a parameter count mismatch between the query and method parameters
              at com.sun.sql.QueryObjectGeneratorImpl.getUpdateImpl(Unknown Source)
              at com.sun.sql.QueryObjectGeneratorImpl.invoke(Unknown Source)
              at $Proxy0.InsertOne(Unknown Source)
              at EOD_update.main(EOD_update.java:52)


      Specific Machine Info:
      =====================
       SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60






      ###@###.### 2005-07-20 21:47:57 GMT

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: