JDBC/MySql problem with Unicode

This is a discussion on JDBC/MySql problem with Unicode within the JDBC JAVA forums in Framework and Interface Programming category; Hi all, I have been struggling to get MySql to accept Unicode characters for a while now with no success. I am attaching a small example program as well as a mySql dump in hopes that someone can help. The expected behavior is that the program should insert a curly quote and a 'one quarter' symbol. It gets the 'one quarter' symbol, but not the curly quote (unicode char 201C). Any help much appreciated. MySql version - 4.1.4-gamma-nt-log Connecto/J version - 3.0.10 table dump: ---------------------------------------- use testchar; DROP TABLE IF EXISTS `testchar`; CREATE TABLE `testchar` ( `testchar` varchar(100) NOT NULL ...

Go Back   Application Development Forum > Framework and Interface Programming > JDBC JAVA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-25-2004, 03:20 PM
Barley
Guest
 
Default JDBC/MySql problem with Unicode

Hi all,

I have been struggling to get MySql to accept Unicode characters for a while
now with no success. I am attaching a small example program as well as a
mySql dump in hopes that someone can help.

The expected behavior is that the program should insert a curly quote and a
'one quarter' symbol. It gets the 'one quarter' symbol, but not the curly
quote (unicode char 201C). Any help much appreciated.

MySql version - 4.1.4-gamma-nt-log
Connecto/J version - 3.0.10

table dump:
----------------------------------------
use testchar;
DROP TABLE IF EXISTS `testchar`;
CREATE TABLE `testchar` (
`testchar` varchar(100) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
----------------------------------------

test code snippet:
----------------------------------------
try {

Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection(

"jdbc:mysql://localhost/testchar?user=root&useUnicode=true&charact er
Encoding=utf8");
java.sql.Statement select = conn.createStatement();
select.executeUpdate("insert into testchar (testchar) values ('problem
characters - \u201C ... \u00BC')");
ResultSet r = select.executeQuery("select testchar from testchar");
while (r.next()) {
System.out.println(r.getString(1));
}
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}
-----------------------------------------

The output should be:
problem characters - " ... ¼

Instead, it is:
problem characters - ? ... ¼

Many MANY grateful thanks to anyone who can tell me what I am doing wrong.
This has been very frustrating.

Gregg


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:10 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.