[ http://issues.apache.org/jira/browse/DERBY-1335?page=comments#action_12413108 ]
Andrei Badea commented on DERBY-1335: ------------------------------------- I tried with db-derby-snapshot-10.1.2.4-405564 and couldn't reproduce the bug. It seems it has been fixed, please feel free to close this issue. > The object names in SQLException messages are not in UTF-16 > ----------------------------------------------------------- > > Key: DERBY-1335 > URL: http://issues.apache.org/jira/browse/DERBY-1335 > Project: Derby > Type: Bug > Components: Network Client > Versions: 10.1.2.1 > Environment: Debian unstable, Linux 2.6.14.2, libc 2.3.5-8, Sun JDK > 1.5.0_05-b05, Derby 10.1.2.1 > Reporter: Andrei Badea > Priority: Minor > > The object names in SQLException messages are not in UTF-16, although they > are sent to the server in that encoding. For example, when adding a both NULL > and UNIQUE column the resulting exception message will contain the column > name (like in "'é' cannot be a column of a primary key or unique key because > it can contain null values.'). If the column name contained characters > outside the range U+0000..U+007F these characters are not encoded in UTF-16 > in the exception message. Can only reproduce with the client driver, the > embedded driver behaves as expected. > Code to reproduce the issue (have a database called "sample" containing a > table called "TEST"): > -----%<----- > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.SQLException; > import java.sql.Statement; > public class MainDerby { > public static void main(String[] args) throws Exception { > Class.forName("org.apache.derby.jdbc.ClientDriver"); > > Connection conn = > DriverManager.getConnection("jdbc:derby://localhost:1527/sample", "app", > "app"); > try { > String tableName = "é"; > System.out.println("Table name code point: " + > (int)tableName.charAt(0)); > Statement stmt = conn.createStatement(); > stmt.executeUpdate("ALTER TABLE test ADD \"" + tableName + "\" > INT UNIQUE"); > } catch (SQLException e) { > String message = e.getMessage(); // '??' cannot be a column of a > primary key or unique key because it can contain null values. > System.out.println("Exception message: " + message); > System.out.print("Table name code points in exception message: "); > if (message.charAt(0) == '\'') { // > int i = 1; > char ch = message.charAt(i); > while (ch != '\'') { > System.out.print((int)ch); > System.out.print(" "); > i++; > ch = message.charAt(i); > } > } > System.out.println(); > } finally { > conn.close(); > } > } > } > -----%<----- > This program produces the following output: > -----%<----- > Table name code point: 233 > Exception message: '??' cannot be a column of a primary key or unique key > because it can contain null values. > Table name code points in exception message: 258 352 > -----%<----- > Note "??" is the UTF-8 representation of "é". > This was initially reported as NetBeans issue 76584 > (http://www.netbeans.org/issues/show_bug.cgi?id=76584). -- 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
