This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Only one chinese charcter '塚' cant able to insert by JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Only one chinese charcter Watch "Only one chinese charcter New topic

Only one chinese charcter '塚' cant able to insert by JDBC

Imtiaz Ahmed

Joined: Dec 01, 2008
Posts: 12
As You can see that in the below code there are two characters

I can able to insert 2 but not 1
when i am insert by sqlplus its inserting i mean the 2 character
where as when i use JDBC its not inserting instead it gives '?'

when i quered
it gave me ZHS16CGB231280

Can anyone help me in inserting this character properly into database


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class InsertIntoDB {

* @param args
* con=DriverManager.getConnection(
static String userid="XGLIVE", password = "AIOICHLIVE";
static String url = "jdbcracle:thin:@";// String url = "jdbc:mySubprotocol:myDataSource"; ?
static Statement stmt;
static Connection con;

public static void main(String[] args) {
// TODO Auto-generated method stub

System.out.println("Enter the value want to Insert");
/*BufferedReader br = new BufferedReader(new InputStreamReader(;
String value = null;

try {
value = br.readLine();
} catch (IOException ioe) {
System.out.println("IO error trying to read your value");
} */

con = getConnection();

String str="塚";
//String str="天";

String InsertStatement="";
String s = new String(str.getBytes(), "GB2312");
InsertStatement="insert into chinesechar values('"+s+"')";
} catch (UnsupportedEncodingException e) {
// just ignore, if the named encoding is not supported.

InsertStatement="insert into chinesechar values('"+str+"')";
//String InsertStatement="insert into chinesechar values('天')";

try {
stmt = con.createStatement();

System.out.println("Your Value is Inserted");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());

public static Connection getConnection()

try {

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");

try {
con = DriverManager.getConnection(url,
userid, password);

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());

return con;

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43935
Please confirm that your present question is different from your earlier question; otherwise it would be better to continue with one thread.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Only one chinese charcter '塚' cant able to insert by JDBC
It's not a secret anymore!