db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6214) PreparedStatement.setObject(int, Object, Types.CLOB) fail with DerbyNet
Date Thu, 23 May 2013 19:37:21 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13665534#comment-13665534
] 

Mamta A. Satoor commented on DERBY-6214:
----------------------------------------

I think the unique number of 10923 characters comes from the following code in the client
side. Here we decide when to send the data as string vs stream
Thread [main] (Suspended (breakpoint at line 1366 in NetStatementRequest))	
	NetResultSetRequest(NetStatementRequest).computeProtocolTypesAndLengths(Object[], ColumnMetaData,
int[][], Hashtable) line: 1366	
	NetResultSetRequest(NetStatementRequest).buildSQLDTAcommandData(int, ColumnMetaData, Object[])
line: 545	
	NetResultSetRequest(NetStatementRequest).writeExecute(NetPreparedStatement, Section, ColumnMetaData,
Object[], int, boolean, boolean) line: 162	
	NetPreparedStatement.writeExecute_(Section, ColumnMetaData, Object[], int, boolean, boolean)
line: 156	
	ClientPreparedStatement.writeExecute(Section, ColumnMetaData, Object[], int, boolean, boolean)
line: 1832	
	ClientPreparedStatement.flowExecute(int) line: 2047	
	ClientPreparedStatement.executeX() line: 1620	
	ClientPreparedStatement.execute() line: 1605	
	MamtaJDBC.main(String[]) line: 84	

                case Types.LONGVARCHAR:
                    // Is this the right thing to do  // should this be 32700
                    s = (String) inputRow[i];
                    if (s == null || s.length() <= 32767 / 3) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLONGMIX;
                        lidAndLengths[i][1] = 32767;
                    } else {
                        // Flow the data as CLOB data if the data too large to for LONGVARCHAR
                        ByteArrayInputStream bais = null;
                        byte[] ba = null;
                        try {
                            ba = s.getBytes("UTF-8");
                            bais = new ByteArrayInputStream(ba);
                            ClientClob c = new ClientClob(
                                netAgent_, bais, "UTF-8", ba.length);

                            // inputRow[i] = c;
                            // Place the new Lob in the promototedParameter_ collection for
                            // NetStatementRequest use
                            promototedParameters_.put(i, c);

                            lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBCMIXED;
                            lidAndLengths[i][1] = buildPlaceholderLength(c.length());
                        } catch (UnsupportedEncodingException e) {
                            throw new SqlException(netAgent_.logWriter_, 
                                new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
                                "byte array", "Clob");
                        }
                    }
                    break;

                
> PreparedStatement.setObject(int, Object, Types.CLOB) fail with DerbyNet
> -----------------------------------------------------------------------
>
>                 Key: DERBY-6214
>                 URL: https://issues.apache.org/jira/browse/DERBY-6214
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.8.3.0, 10.9.1.0
>            Reporter: Rong Qu
>            Assignee: Mamta A. Satoor
>         Attachments: Derby6214.java, Derby6214_setup.sql, Derby6214_ver2.java, derby.log,
DerbyNet_client_test.sql
>
>
> The issue is specific to the DerbyNet client driver, and doesn't seem to occur using
embedded Derby.
>  "PreparedStatement.setObject(int, Object, Types.CLOB)". It seems to be a problem updating
a CLOB column with a parameterized value using the DerbyNet client driver, and if the update
SQL ends up updating more than one row. I attached a simple test case that just uses JDBC
to reproduce the error. The exception looks like this:
> org.apache.derby.client.am.BatchUpdateException: Non-atomic batch failure.  The batch
was submitted, but at least one exception occurred on an individual member of the batch. Use
getNextException() to retrieve the exceptions for specific batched elements.
>     at org.apache.derby.client.am.Agent.endBatchedReadChain(Unknown Source)
>     at org.apache.derby.client.am.PreparedStatement.executeBatchRequestX(Unknown Source)
>     at org.apache.derby.client.am.PreparedStatement.executeBatchX(Unknown Source)
>     at org.apache.derby.client.am.PreparedStatement.executeBatch(Unknown Source)
>     ...
> Caused by: org.apache.derby.client.am.SqlException: Error for batch element #0: An unexpected
exception was thrown
>     at org.apache.derby.client.am.Statement.completeExecute(Unknown Source)
>     at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
>     at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
>     at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
>     at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
>     at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source)
>     ... 4 more
> Caused by: org.apache.derby.client.am.SqlException: Error for batch element #0: Java
exception: 'Stream has already been read and end-of-file reached and cannot be re-used.: java.io.EOFException'.
>     at org.apache.derby.client.am.SqlException.<init>(Unknown Source)
>     at org.apache.derby.client.am.SqlException.<init>(Unknown Source)
>     ... 10 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message