You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kristian Waagan (JIRA)" <ji...@apache.org> on 2010/05/31 15:56:41 UTC

[jira] Updated: (DERBY-3752) NullPointerException when inserting a blob in autocommit mode with an open result set

     [ https://issues.apache.org/jira/browse/DERBY-3752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan updated DERBY-3752:
-----------------------------------

    Attachment: Derby3752Repro.java

Copied Dyre's repro code from the description into a file.

> NullPointerException when inserting a blob in autocommit mode with an open result set
> -------------------------------------------------------------------------------------
>
>                 Key: DERBY-3752
>                 URL: https://issues.apache.org/jira/browse/DERBY-3752
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.4.1.3
>            Reporter: Dyre Tjeldvoll
>         Attachments: Derby3752Repro.java
>
>
> Leaving a result set is left open in autocommit mode will trigger an NPE when attempting to insert a BLOB. Calling executeUpdate() to insert the BLOB appears to trigger a commit because of the open rs which in turn also frees the very BLOB you are trying to insert. 
> To reproduce:
>         Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>         Connection c =
>             DriverManager.getConnection("jdbc:derby:db;create=true");
>         Statement s = c.createStatement();
>         try {
>             s.execute("create table b (b blob)");
>         } catch (Exception e) { System.out.println(e); }
>         
>         s.executeQuery("VALUES 1"); // Closing this result set makes the problem disappear
>         PreparedStatement ps = c.prepareStatement(
>             "insert into b values ?");
>         Blob b = c.createBlob();
>         b.setBytes(1, new byte[0]);
>         ps.setBlob(1, b);
>         ps.executeUpdate();
> Call stack:
> Exception in thread "main" java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
>         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
>         at org.apache.derby.impl.jdbc.Util.javaException(Util.java:244)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
>         at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2179)
>         at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
>         at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1325)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1652)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:301)
>         at repro.Main.main(Main.java:44)
> Caused by: java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70)
>         ... 10 more
> Caused by: java.lang.NullPointerException
>         at org.apache.derby.impl.jdbc.LOBStreamControl.read(LOBStreamControl.java:271)
>         at org.apache.derby.impl.jdbc.LOBInputStream.read(LOBInputStream.java:166)
>         at java.io.FilterInputStream.read(FilterInputStream.java:66)
>         at org.apache.derby.iapi.services.io.LimitInputStream.read(LimitInputStream.java:48)
>         at org.apache.derby.iapi.types.RawToBinaryFormatStream.checkSufficientData(RawToBinaryFormatStream.java:219)
>         at org.apache.derby.iapi.types.RawToBinaryFormatStream.read(RawToBinaryFormatStream.java:280)
>         at org.apache.derby.impl.store.raw.data.MemByteHolder.write(MemByteHolder.java:146)
>         at org.apache.derby.impl.store.raw.data.RememberBytesInputStream.fillBuf(RememberBytesInputStream.java:135)
>         at org.apache.derby.impl.store.raw.data.StoredPage.logColumn(StoredPage.java:6156)
>         at org.apache.derby.impl.store.raw.data.StoredPage.logRow(StoredPage.java:3970)
>         at org.apache.derby.impl.store.raw.data.InsertOperation.writeOptionalDataToBuffer(InsertOperation.java:370)
>         at org.apache.derby.impl.store.raw.data.InsertOperation.<init>(InsertOperation.java:115)
>         at org.apache.derby.impl.store.raw.data.LoggableActions.actionInsert(LoggableActions.java:139)
>         at org.apache.derby.impl.store.raw.data.BasePage.insertAllowOverflow(BasePage.java:763)
>         at org.apache.derby.impl.store.raw.data.BasePage.insert(BasePage.java:653)
>         at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:307)
>         at org.apache.derby.impl.store.access.heap.HeapController.insert(HeapController.java:575)
>         at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:457)
>         at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1011)
>         at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:487)
>         at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:384)
>         at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1235)
>         ... 3 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.