Derby
  1. Derby
  2. DERBY-4224

Commit after setAsciiStream() makes execution fail with the client driver

    Details

    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Deviation from standard, Embedded/Client difference, Regression

      Description

      Got below error message when running a JDBC prolgram with derby. I use Apache Derby Network Server - 10.4.2.0 - (689064). The same program works fine with another version Apache Derby Network Server - 10.2.2.0 - (485682). It looks like there is a regression between the two versions.
      Exception in thread "main" java.sql.SQLException: You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back.
      at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
      at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
      at org.apache.derby.client.am.Lob.checkValidity(Unknown Source)
      at org.apache.derby.client.am.Clob.length(Unknown Source)
      at org.apache.derby.client.net.NetStatementRequest.computeProtocolTypesAndLengths(Unknown Source)
      at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(Unknown Source)
      at org.apache.derby.client.net.NetStatementRequest.writeExecute(Unknown Source)
      at org.apache.derby.client.net.NetPreparedStatement.writeExecute_(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.writeExecute(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.executeX(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.execute(Unknown Source)
      at DerbyTest.test(DerbyTest.java:36)
      at DerbyTest.main(DerbyTest.java:12)
      Caused by: org.apache.derby.client.am.SqlException: You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back.
      ... 12 more

      Below is the test program I used.

      import java.io.ByteArrayInputStream;
      import java.io.IOException;
      import java.io.InputStream;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.SQLException;
      import java.sql.Statement;

      public class DerbyTest {
      public static void main(String[] args) throws SQLException, IOException

      { new DerbyTest().test(); }

      private void test() throws SQLException, IOException {
      Connection conn = null;

      try

      { conn = getConnection(); Statement stmt = conn.createStatement(); dropTable("test1"); dropTable("test2"); String createStr1 = "CREATE TABLE test1 (col0 VARCHAR(8000))"; String createStr2 = "CREATE TABLE test2 (col0 VARCHAR(8000))"; stmt.executeUpdate(createStr1); stmt.executeUpdate(createStr2); stmt.close(); PreparedStatement pstmt1 = conn.prepareStatement("INSERT INTO test1 VALUES (?)"); PreparedStatement pstmt2 = conn.prepareStatement("INSERT INTO test1 VALUES (?)"); InputStream in1 = new ByteArrayInputStream("abcdefghijklmnopqrstuvwxyz0123456789".getBytes()); InputStream in2 = new ByteArrayInputStream("9876543210ZYXWVUTSRQPONMLKJIHGFEDCBA".getBytes()); pstmt1.setAsciiStream(1, in1, in1.available()); pstmt2.setAsciiStream(1, in2, in2.available()); pstmt1.execute(); pstmt2.execute(); pstmt1.close(); pstmt2.close(); System.out.println("Successful"); }

      finally

      { if (conn != null) conn.close(); }

      }

      private Connection getDriverConnection() throws SQLException

      { String connectionURL = "jdbc:derby://localhost:1527/testdb;user=app;password=derby;create=true"; return DriverManager.getConnection(connectionURL); }

      private Connection getConnection() throws SQLException

      { return getDriverConnection(); }

      public void dropTable(String tableName) throws SQLException {
      Connection conn = getConnection();
      Statement stmt = conn.createStatement();
      try

      { stmt.executeUpdate("DROP TABLE " + tableName); }

      catch (SQLException sqle)

      { System.out.println("Error occured when drop table: " + sqle.getMessage()); }

      finally {
      if (stmt != null)

      { stmt.close(); }

      if (conn != null)

      { conn.close(); }

      }
      }
      }

        Issue Links

          Activity

          Gavin made changes -
          Workflow jira [ 12463173 ] Default workflow, editable Closed status [ 12800235 ]
          Kathey Marsden made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Kathey Marsden made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Bug behavior facts [Regression, Embedded/Client difference] [Deviation from standard, Embedded/Client difference, Regression]
          Fix Version/s 10.4.2.1 [ 12313401 ]
          Fix Version/s 10.5.2.1 [ 12314117 ]
          Fix Version/s 10.6.0.0 [ 12313727 ]
          Resolution Fixed [ 1 ]
          Kathey Marsden made changes -
          Assignee Kathey Marsden [ kmarsden ]
          Kathey Marsden made changes -
          Link This issue is related to DERBY-3574 [ DERBY-3574 ]
          Kathey Marsden made changes -
          Link This issue is related to DERBY-4312 [ DERBY-4312 ]
          Dag H. Wanvik made changes -
          Urgency Normal
          Issue & fix info [Repro attached]
          Dag H. Wanvik made changes -
          Bug behavior facts [Regression] [Embedded/Client difference, Regression]
          Dag H. Wanvik made changes -
          Bug behavior facts [Embedded/Client difference] [Regression]
          Knut Anders Hatlen made changes -
          Field Original Value New Value
          Summary Got SQLException Commit after setAsciiStream() makes execution fail with the client driver
          Derby Categories [Regression Test Failure] [Embedded/Client difference]
          Derby Info [Regression]
          Component/s Network Client [ 11690 ]
          Simon Meng created issue -

            People

            • Assignee:
              Kathey Marsden
              Reporter:
              Simon Meng
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development