-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: does JDBC support Chinese column name ?
PostPosted: Fri Apr 16, 2010 12:12 pm 
Beginner
Beginner

Joined: Mon Feb 02, 2009 3:22 am
Posts: 26
Hi

I am using MySQL 5, and created a table with Chinese column name like the following:

CREATE TABLE contacts (
联系电话 varchar(20) ,
客户姓名 varchar(50) ,
PRIMARY KEY(联系电话,客户姓名)
) ENGINE=InnoDB DEFAULT CHARSET=gbk ROW_FORMAT=REDUNDANT;



My jdbc code:

rs = stmt.executeQuery("select * from contacts");
ResultSetMetaData rsMetaData = rs.getMetaData();

int columnCount = rsMetaData.getColumnCount();
System.out.println("columnCount=" + columnCount);
for(int i=1; i<=columnCount; i++)
{
System.out.print( rsMetaData.getColumnName(i));
System.out.println();
}


while (rs.next())
{

System.out.print(rs.getString("联系电话") + ", ");
System.out.print(rs.getString("客户姓名") + ", ");
System.out.println();
}

The result:

columnCount=2
è?”????”?è??
?????·?§“???
java.sql.SQLException: Column '联系电话' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:987)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5584)
at com.ictbox.acc.agenttoolbar.db.JdbcTest.main(JdbcTest.java:45)


I have set the default-character-set to gbk for the server, and add "useUnicode=true&characterEncoding=gbk" parameter in the connection string, but it didn't help
Does JDBC support Chinese column name ? Is there any way to solve this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.