[ http://issues.apache.org/jira/browse/DERBY-1127?page=all ]
Sunitha Kambhampati updated DERBY-1127:
---------------------------------------
Attachment: derby1127.p1.diff.txt
derby1127.p1.stat.txt
This patch (derby1127.p1.diff.txt, derby1127.p1.stat.txt) fixes the encoding
issue with date,time,timestamp that was the cause for the failures for these 2
tests on z/os.
On client side, java.sql.Time, java.sql.Date, java.sql.Timestamp are converted
to a char representation and then sent across as bytes to server. Server
expects these bytes to have been encoded using UTF8. Client currently uses the
default encoding. Thus on a client jvm where encoding is different from UTF8,
the data sent to server results in not being in the expected format and error
is thrown.
For set parameter calls, ie setDate etc, the client calls
DateTime.dateToDateBytes etc where a String(char[]).getBytes() is used. see
methods in Request.java for writeDate,writeTimestamp,writeTime
Server side, the parameters sent on SQLDTA objects, are read and parameters are
set on the statement in DRDAConnThread.readAndsetParams. If server does not
receive the date, time, timestamp parameters in expected format, the following
exception is raised.
> java.sql.SQLException: The syntax of the string representation of a datetime
> value is incorrect.
This patch fixes
-- the calls in DateTime to use correct UTF8 encoding as the server expects.
-- adds these two tests (callable.java, parameterMapping.java) to encodingTests
Testing
-- code only affects client. I have run derbynetclientmats and derbynetmats on
linux/ibm142 wiht no new failures.
-- ran encodingTests suite on jdk15/windows ok.
-- ran derbynetclientmats and derbynetmats on Z/OS OK. There are still some
more issues to resolve on z/os, but these 2 tests pass on z/os. (As an aside -
after the fix to this issue - the datetime diffs got resolved in csPrepStmt and
prepstmt but they were failing with a different diff, which is a test problem.
There is an exisiting jira (DERBY972) for it. I will attach a separate patch
for that. )
can someone please look at this patch. Thanks.
-------------
Question:
Server expects the date,time,timestamp to be in a specific format and also
encoded with UTF8. My question is should we specify CCSID for these types given
that we are expecting them to be encoded in a specific format. On a parameter
describe for input parameters, as I checked the flow in the debugger - I
realized the server does not sent CCSID for timestamp values. We only send for
char parameters.
I looked at spec briefly in fdoc manual and didnt find anything specific about
timestamp datatypes. I think maybe these would fall under the numeric character
strings(?). This needs to be investigated more along with areas mentioned in
DERBY-877.
> client gives SqlException for test callable.java and parameterMapping.java on
> zOS
> ---------------------------------------------------------------------------------
>
> Key: DERBY-1127
> URL: http://issues.apache.org/jira/browse/DERBY-1127
> Project: Derby
> Type: Bug
> Components: Network Client
> Versions: 10.1.2.0
> Environment: OS/390 (zOS) with ibm 142 jvm ('classic' - 32 bit)
> Reporter: Myrna van Lunteren
> Attachments: derby1127.p1.diff.txt, derby1127.p1.stat.txt
>
> On zOS, the tests callable.java and parameterMapping.java failed with
> networkserver and the derby client. The failure did not occur with the
> db2jcc.jar.
> The stack trace was as follows:
> org.apache.derby.client.am.SqlException:
> ^V^V^30^30^D^F^53^F^31^38^31 :
> at
> org.apache.derby.client.am.Statement.completeExecute(Statement.java:1139)
> at
> org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(NetStatementReply.java:296)
> at
> org.apache.derby.client.net.NetStatementReply.readExecuteCall(NetStatementReply.java:97)
> at
> org.apache.derby.client.net.StatementReply.readExecuteCall(StatementReply.java:74)
> at
> org.apache.derby.client.net.NetStatement.readExecuteCall_(NetStatement.java:174)
> at
> org.apache.derby.client.am.Statement.readExecuteCall(Statement.java:1105)
> at
> org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:1426)
> at
> org.apache.derby.client.am.CallableStatement.executeX(CallableStatement.java:124)
> at
> org.apache.derby.client.am.CallableStatement.execute(CallableStatement.java:114)
> at
> org.apache.derbyTesting.functionTests.tests.derbynet.callable.main(Unknown
> Source)
> In callable.java, it's this part of the test that caused the failure:
> ------------------------------------------
> System.out.println("return value is: " + cs.getInt(1));
> cs.close();
> // stmt.execute("DROP FUNCTION method4");
> // different parameter types, also method overload
> stmt.execute("CREATE PROCEDURE method4P(" +
> "IN P1 SMALLINT, IN P2 INT, IN P3 BIGINT, IN P4 REAL, " +
> "IN P5 DOUBLE, IN P6 DECIMAL(6,3), IN P7 DATE, IN P8 TIME, IN
> P9 TIMESTAMP, IN P10 VARCHAR(20) FOR BIT DATA, " +
> "OUT O1 SMALLINT, OUT O2 INT, OUT O3 BIGINT, OUT O4 REAL, " +
> "OUT O5 DOUBLE, OUT O6 DECIMAL(6,3), OUT O7 DATE, OUT O8 TIME,
> OUT O9 TIMESTAMP, OUT O10 VARCHAR(20) FOR BIT DATA" +
> ") " +
> "EXTERNAL NAME
> 'org.apache.derbyTesting.functionTests.tests.derbynet.callable.method4'" +
> " NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA");
> cs = conn.prepareCall("call method4P(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?)");
> cs.setShort(1, (short) 3);
> cs.setInt(2, 4);
> cs.setLong(3, 5);
> cs.setFloat(4, (float) 6.0);
> cs.setDouble(5, 7.0);
> cs.setBigDecimal(6, new BigDecimal("88.88"));
> cs.setDate(7, Date.valueOf("2002-05-12"));
> cs.setTime(8, Time.valueOf("10:05:02"));
> cs.setTimestamp(9, Timestamp.valueOf("2002-05-12 10:05:02.000000000"));
> byte[] ba = new byte[2];
> ba[0] = 1;
> ba[1] = 2;
> cs.setBytes(10, ba);
> int n = 10;
> cs.registerOutParameter (n+1, java.sql.Types.SMALLINT);
> cs.registerOutParameter (n+2, java.sql.Types.INTEGER);
> cs.registerOutParameter (n+3, java.sql.Types.BIGINT);
> cs.registerOutParameter (n+4, java.sql.Types.REAL);
> cs.registerOutParameter (n+5, java.sql.Types.DOUBLE);
> cs.registerOutParameter (n+6, java.sql.Types.DECIMAL);
> cs.registerOutParameter (n+7, java.sql.Types.DATE);
> cs.registerOutParameter (n+8, java.sql.Types.TIME);
> cs.registerOutParameter (n+9, java.sql.Types.TIMESTAMP);
> cs.registerOutParameter (n+10, java.sql.Types.VARBINARY);
> cs.execute();
> ------------------
> I found in derby.log a reference to error 22007, (.S.181) - i.e. syntax
> error on parameter 3 of SYSIBM.SQLCAMESSAGE (yes, this is from last year):
> -------------------------------
> 2005-09-10 01:56:17.009 GMT Thread[DRDAConnThread_2,5,main]
> (XID = 110), (SESSIONID = 0), (DATABASE = wombat), (DRDAID =
> NF000001.G7C1-4327676640608975420{2}),
> End compiling prepared statement: call method4P(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) :End prepared statement
> 2005-09-10 01:56:17.311 GMT Thread[DRDAConnThread_2,5,main]
> (XID = 110), (SESSIONID = 0), (DATABASE = wombat), (DRDAID =
> NF000001.G7C1-4327676640608975420{2}),
> Begin compiling prepared statement: call
> SYSIBM.SQLCAMESSAGE(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) :End prepared statement
> 2005-09-10 01:56:17.429 GMT Thread[DRDAConnThread_2,5,main]
> (XID = 110), (SESSIONID = 0), (DATABASE = wombat), (DRDAID =
> NF000001.G7C1-4327676640608975420{2}),
> End compiling prepared statement: call
> SYSIBM.SQLCAMESSAGE(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) :End prepared statement
> 2005-09-10 01:56:17.831 GMT Thread[DRDAConnThread_2,5,main]
> (XID = 110), (SESSIONID = 0), (DATABASE = wombat), (DRDAID =
> NF000001.G7C1-4327676640608975420{2}),
> Executing prepared statement: call
> SYSIBM.SQLCAMESSAGE(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) :End prepared statement
> with 16 parameters begin
> parameter #1: -1 :end p
> arameter begin parameter #2: 11 :end parameter begin parameter
> #3: ^V^V^30^30^D^
> F^53^F^31^38^31 :end parameter begin parameter #4:
> ^43^53^53^31^30^30^31^31 :end
> parameter begin parameter #5: 0 :end parameter begin parameter
> #6: 0 :end param
> eter begin parameter #7: 0 :end parameter begin parameter #8: 0
> :end parameter begin parameter #9: 0 :end parameter begin parameter #10: 0
> :end
> parameter begin
> parameter #11: ^20^20^20^20^20^20^20^20^20^20^20 :end parameter
> begin parameter
> #12: ^V^V^30^30^D :end parameter begin parameter #13: null :end
> parameter begin
> parameter #14: en :end parameter begin parameter #15: null :end
> parameter begin
> ----------------------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira