[
http://issues.apache.org/jira/browse/DERBY-2104?page=comments#action_12453972 ]
Fernanda Pizzorno commented on DERBY-2104:
------------------------------------------
My repro was not exactly what I expected to report, and it is true that it is
just an encoding issue.
The actual error I came across is a bit different. While converting the test
lang/updatableResultSet.java to Junit I found and error in the method that
verifies that the update done using different combinations of updateXXX methods
and SQL data types, namely verfyData(). This error caused that not all
combinations where actually being verified. Fixing this, so that all
combinations would be verified, uncovered a few issues including the one I
tried to describe in this JIRA issues. I have now written a better repro for
what is being tested in lang/updatableResultSet.java:
Statement stmt1 = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
Statement stmt2 = conn.createStatement();
stmt1.executeUpdate("CREATE TABLE t1 (i int, c char(60))");
stmt1.executeUpdate("CREATE TABLE t2 (i int, c VARCHAR(20) FOR BIT
DATA)");
stmt1.executeUpdate("INSERT INTO t1 values (1, 'xx')");
stmt1.executeUpdate("INSERT INTO t2 values (1, X'10bb')");
ResultSet rs1 = stmt1.executeQuery("SELECT * FROM t1");
ResultSet rs2 = stmt2.executeQuery("SELECT * FROM t2");
if (!rs1.next()) {
System.out.println("Row not found");
return;
}
if (!rs2.next()) {
System.out.println("Row not found");
return;
}
rs1.updateBytes(2, rs2.getBytes(2));
rs1.updateRow();
rs1.close();
rs1 = stmt1.executeQuery("SELECT * FROM t1");
if (!rs1.next()) {
System.out.println("Row not found");
return;
}
if (!rs1.getString(2).trim().equals(rs2.getString(2))) {
System.out.println("FAIL - wrong string value for column 2.
" +
"Expected: " + rs2.getString(2) + " but was: " +
rs1.getString(2));
}
The problem is that calling the getString method on the CHAR column returns
"\u10bb" while calling the same method on the BINARY column returns a String
with the hexadecimal representation of the byte array "10bb".
> Embedded - Column of type CHAR, VARCHAR or LONG VARCHAR contains wrong value
> after being updated using the ResultSet.updateBytes() method.
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2104
> URL: http://issues.apache.org/jira/browse/DERBY-2104
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Reporter: Fernanda Pizzorno
>
> REPRO:
> Statement stmt1 =
> conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
> ResultSet.CONCUR_UPDATABLE);
>
> stmt1.executeUpdate("CREATE TABLE t1 (i int, c char(60))");
> stmt1.executeUpdate("INSERT INTO t1 values (1, 'xx')");
>
> ResultSet rs1 = stmt1.executeQuery("SELECT * FROM t1");
>
> if (!rs1.next()) {
> System.out.println("Row not found");
> return;
> }
>
> rs1.updateBytes(2, "NEW VALUE".getBytes());
> rs1.updateRow();
> rs1.close();
>
> rs1 = stmt1.executeQuery("SELECT * FROM t1");
> if (!rs1.next()) {
> System.out.println("Row not found");
> return;
> }
>
> if (!rs1.getString(2).equals("NEW VALUE")) {
> System.out.println("FAIL - wrong string value for column 2. "
> +
> "Expected: NEW VALUE but was: " + rs1.getString(2));
> }
> OUTPUT:
> FAIL - wrong string value for column 2. Expected: NEW VALUE but was: ?????
--
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