Less than or equal symbol dissapears with Connector/J
Posted by: Rob Frampton
Date: September 26, 2009 06:10PM

Hi,

I know the topic of the handling of Unicode in Connector/J has come up several times before, but none of the solutions suggested seem to solve it, although I'm sure it is a Unicode problem.

My Java app is trying to store a Less Than or Equal To symbol, which is part of UTF-8 (http://www.fileformat.info/info/unicode/char/2264/index.htm), however it always inserts a ? in place of the symbol once in the database. I can paste it into the mysql CLI client and it works fine. If I use the following JDBC connect string:

?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8

I actually get an exception when inserting:

Caused by: java.sql.SQLException: Incorrect string value: '\xE2\x89\xA4 5 ...' for column 'Description' at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2086)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2289)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2274)
at com.mysql.jdbc.UpdatableResultSet.insertRow(UpdatableResultSet.java:857)
at...
Caused by:
java.sql.SQLException: Incorrect string value: '\xE2\x89\xA4 5 ...' for column 'Description' at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2086)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2289)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2274)
at com.mysql.jdbc.UpdatableResultSet.insertRow(UpdatableResultSet.java:857)
at...

Yet as far as I can see, \xE2\x89\xA4 is perfectly valid UTF-8. Can anyone shed any light on this?

Many thanks.

Options: ReplyQuote


Subject
Written By
Posted
Less than or equal symbol dissapears with Connector/J
September 26, 2009 06:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.