Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 59162 invoked from network); 28 Jul 2008 14:40:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jul 2008 14:40:31 -0000 Received: (qmail 17705 invoked by uid 500); 28 Jul 2008 14:40:30 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 17676 invoked by uid 500); 28 Jul 2008 14:40:30 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 17665 invoked by uid 99); 28 Jul 2008 14:40:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 07:40:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 14:39:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E7021234C183 for ; Mon, 28 Jul 2008 07:39:31 -0700 (PDT) Message-ID: <1876599493.1217255971945.JavaMail.jira@brutus> Date: Mon, 28 Jul 2008 07:39:31 -0700 (PDT) From: "Kristian Waagan (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-3799) NullPointerException when accessing a clob through a pooled connection In-Reply-To: <1110809303.1216994251915.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3799?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan updated DERBY-3799: ----------------------------------- Attachment: derby-3799-1a-checkIfClosed.diff 'derby-3799-1a-checkIfClosed.diff' fixes the reported problem and adds a re= gression test. When a logical connection is closed all open statements are closed. The LOB= stored procedure code did not detect this, as it only checked if the refer= ence to the CallableStatement was null or not. I fixed this by also checking if the CallableStatement is open on the clien= t. The fix implies that the stored procedure calls must be prepared for eac= h logical connection, if the LOB stored procedures are needed. This does no= t happen when the JDBC statement cache is enabled. Comments on the fix approach and the patch are welcome! > NullPointerException when accessing a clob through a pooled connection > ---------------------------------------------------------------------- > > Key: DERBY-3799 > URL: https://issues.apache.org/jira/browse/DERBY-3799 > Project: Derby > Issue Type: Bug > Components: Network Client > Affects Versions: 10.4.1.3, 10.5.0.0 > Environment: ------------------ Java-Informationen --------------= ---- > Java-Version: 1.6.0 > Java-Anbieter: Sun Microsystems Inc. > Java-Home: C:\Program Files\Java\jdk1.6.0\jre > Java-Klassenpfad: C:\PHS\db-derby\db-derby-10.4.1.3-bin\lib\derbyclient.j= ar;C:\PHS\db-derby\db-derby-10.4.1.3-bin\lib\derbytools.jar;C:\PHS\Dvlp\Sch= op\derby-err\build\classes > Name des Betriebssystems: Windows XP > Architektur des Betriebssystems: x86 > Betriebssystemversion: 5.1 > Java-Benutzername: Ralf Lovec > Java-Benutzerausgangsverzeichnis: C:\Documents and Settings\Ralf Lovec > Java-Benutzerverzeichnis: C:\PHS\Dvlp\Schop\derby-err > java.specification.name: Java Platform API Specification > java.specification.version: 1.6 > --------- Derby-Informationen -------- > JRE - JDBC: Java SE 6 - JDBC 4.0 > [C:\PHS\db-derby\db-derby-10.4.1.3-bin\lib\derbytools.jar] 10.4.1.3 - (64= 8739) > [C:\PHS\db-derby\db-derby-10.4.1.3-bin\lib\derbyclient.jar] 10.4.1.3 - (6= 48739) > ------------------------------------------------------ > ----------------- Informationen zur L=EF=BF=BDndereinstellung -----------= ------ > Aktuelle L=EF=BF=BDndereinstellung: [Deutsch/Deutschland [de_DE]] > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [cs] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [de_DE] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [es] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [fr] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [hu] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [it] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [ja_JP] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [ko_KR] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [pl] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [pt_BR] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [ru] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [zh_CN] > Version: 10.4.1.3 - (648739) > Es wurde Unterst=EF=BF=BDtzung f=EF=BF=BDr die folgende L=EF=BF=BDnderein= stellung gefunden: [zh_TW] > Version: 10.4.1.3 - (648739) > ------------------------------------------------------ > Reporter: Ralf Lovec > Assignee: Kristian Waagan > Attachments: derby-3799-1a-checkIfClosed.diff > > > After returning a pooled connection to the pool and getting it again a Nu= llPointerException is thrown when a clob field is accessed again. This may = be related to the following post: http://mail-archives.apache.org/mod_mbox/= db-derby-user/200803.mbox/%3C47CD3431.5020205@sun.com%3E > Here is the stack trace: > java.lang.NullPointerException > at org.apache.derby.client.am.PreparedStatement.setIntX(Unknown S= ource) > at org.apache.derby.client.am.CallableLocatorProcedures.clobGetLe= ngth(Unknown Source) > at org.apache.derby.client.am.Clob.getLocatorLength(Unknown Sourc= e) > at org.apache.derby.client.am.Lob.sqlLength(Unknown Source) > at org.apache.derby.client.am.Clob.length(Unknown Source) > at org.apache.derby.client.am.Cursor.getString(Unknown Source) > at org.apache.derby.client.am.ResultSet.getString(Unknown Source) > at derbyerr.Main.main(Main.java:65) > Here is the code to reproduce the problem: > package derbyerr; > import java.sql.Connection; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.SQLException; > import javax.sql.PooledConnection; > import org.apache.derby.jdbc.ClientConnectionPoolDataSource; > public class Main { > =20 > public static void main (String[] args) { > org.apache.derby.tools.sysinfo.main (args) ; > =20 > ClientConnectionPoolDataSource creator =3D new ClientConnectionPoolDa= taSource () ; > // There should be an empty db named testdb > creator.setDatabaseName ("testdb") ; > =20 > try { > PooledConnection pc =3D creator.getPooledConnection () ; > =20 > Connection c =3D pc.getConnection () ; > PreparedStatement ps ; > ResultSet rs ; > String s ; > // Drop the table "test", if it exsists > try { > ps =3D c.prepareStatement ("drop table test") ; > ps.execute () ; > ps.close () ; > } catch (Exception e) { > } > =20 > // Create a test table with a clob field > ps =3D c.prepareStatement ("create table test (pkey varchar(255) no= t null primary key, value clob)") ; > ps.execute () ; > ps.close () ; > =20 > // Insert a record > ps =3D c.prepareStatement ("insert into test values ('123', 'abc')"= ) ; > ps.execute () ; > ps.close () ; > // Query the record and... > ps =3D c.prepareStatement ("select * from test") ; > rs =3D ps.executeQuery () ; > rs.next () ; > // ...access the clob field - this works > s =3D rs.getString (2) ; > assert s.equals ("abc") ; > rs.close () ; > ps.close () ; > =20 > // Simulate connection pooling: close the connection and get it aga= in > c.close () ; > c =3D pc.getConnection () ; > // Now again query the record... > ps =3D c.prepareStatement ("select * from test") ; > rs =3D ps.executeQuery () ; > rs.next () ; > // ...and access the clob - this fails > s =3D rs.getString (2) ; > assert s.equals ("abc") ; > rs.close () ; > ps.close () ; > =20 > } catch (Exception e) { > e.printStackTrace () ; > } > } > =20 > } --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.