db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Øystein Grøvlen (JIRA) <derby-...@db.apache.org>
Subject [jira] Created: (DERBY-1321) ClassCastException in client for batched statements
Date Fri, 12 May 2006 08:41:30 GMT
ClassCastException in client for batched statements

         Key: DERBY-1321
         URL: http://issues.apache.org/jira/browse/DERBY-1321
     Project: Derby
        Type: Bug

  Components: Network Client  
 Environment: Solaris x86, trunk of March 31st
    Reporter: Øystein Grøvlen
 Attachments: RunDerby.java

In a program using the client driver, I get a ClassCastException when batching prepared statements.
 The code that creates the problem is:

            stmt = connection.createStatement();             	
            stmt.executeUpdate("CREATE TABLE LONGTESTTABLE ( LONG_VALUE NUMERIC(20) )");

            String sql = "insert into LONGTESTTABLE (LONG_VALUE) values ( ? )";
            PreparedStatement pstmt = connection.prepareStatement(sql);

            pstmt.setLong(1, (long)10 ); // long value
            //pstmt.setNull(1, Types.BIGINT ); // THIS WORKS
            pstmt.setNull(1, Types.INTEGER ); // THIS DOES NOT WORK

            int[] updateCounts = pstmt.executeBatch();

If I add the second statement to the batch before the first one, it works.
If I insert an executeBatch() between the statements, it works
If I execute this with the embedded driver, it works

The stack trace I get is:
Exception in thread "main" java.lang.ClassCastException: java.lang.Long
       at org.apache.derby.client.net.NetStatementRequest.buildFDODTA(NetStatementRequest.java:692)
    at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(NetStatementRequest.java:530)
 at org.apache.derby.client.net.NetStatementRequest.writeExecute(NetStatementRequest.java:137)
   at org.apache.derby.client.net.NetPreparedStatement.writeExecute_(NetPreparedStatement.java:118)
        at org.apache.derby.client.am.PreparedStatement.writeExecute(PreparedStatement.java:1336)
       at org.apache.derby.client.am.PreparedStatement.executeBatchRequestX(PreparedStatement.java:1807)
       at org.apache.derby.client.am.PreparedStatement.executeBatchX(PreparedStatement.java:1731)
      at org.apache.derby.client.am.PreparedStatement.executeBatch(PreparedStatement.java:1184)
       at RunDerby.main(RunDerby.java:81)

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message