Index: java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java (revision 611937) +++ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java (working copy) @@ -1249,6 +1249,41 @@ } /** + * Test fix for protocol error if splitQRYDTA occurs during DRDAConnThread.doneData() + * DERBY-3230 + * @throws SQLException + */ + public void testDerby3230() throws SQLException { + Statement s = createStatement(); + s.executeUpdate("CREATE TABLE TAB (col1 varchar(32672) NOT NULL)"); + PreparedStatement ps = prepareStatement("INSERT INTO TAB VALUES(?)"); + ps.setString(1,makeString(15000)); + ps.executeUpdate(); + ps.setString(1,makeString(7500)); + ps.executeUpdate(); + ps.setString(1,makeString(5000)); + ps.executeUpdate(); + ps.setString(1,makeString(2000)); + ps.executeUpdate(); + ps.setString(1,makeString(1600)); + ps.executeUpdate(); + ps.setString(1,makeString(800)); + ps.executeUpdate(); + ps.setString(1,makeString(400)); + ps.executeUpdate(); + ps.setString(1,makeString(200)); + ps.executeUpdate(); + ps.setString(1,makeString(100)); + ps.executeUpdate(); + ps.setString(1,makeString(56)); + ps.executeUpdate(); + + ResultSet rs = s.executeQuery("SELECT * from tab"); + // drain the resultset + JDBC.assertDrainResults(rs); + + } + /** * Return a string of the given length. The string will contain just 'X' * characters. * Index: java/client/org/apache/derby/client/net/NetCursor.java =================================================================== --- java/client/org/apache/derby/client/net/NetCursor.java (revision 611937) +++ java/client/org/apache/derby/client/net/NetCursor.java (working copy) @@ -146,7 +146,12 @@ } NetSqlca[] netSqlca = this.parseSQLCARD(qrydscTypdef_); - + // If we don't have at least one byte in the buffer for the DA null indicator, + // then we need to send a CNTQRY request to fetch the next block of data. + // Read the DA null indicator. Do this before we close mark the statement + // closed on the server. DERBY-3230 + daNullIndicator = readFdocaOneByte(); + if (netSqlca != null) { for (int i=0;i