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 "Daniel John Debrunner (JIRA)" <ji...@apache.org> on 2006/11/27 22:56:22 UTC

[jira] Commented: (DERBY-2104) Embedded - Column of type CHAR, VARCHAR or LONG VARCHAR contains wrong value after being updated using the ResultSet.updateBytes() method.

    [ http://issues.apache.org/jira/browse/DERBY-2104?page=comments#action_12453715 ] 
            
Daniel John Debrunner commented on DERBY-2104:
----------------------------------------------

"NEW VALUE".getBytes() will (most likely)  return a byte array that is not on the encoding expected by Derby, thus the value stored will not map to the string "NEW VALUE".

Looking at the code I think the encoding expected by Derby for byte[] to String is UTF-16.

> 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