my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes store unicode 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 "store unicode" Watch "store unicode" New topic

store unicode

teo peng

Joined: Jul 16, 2001
Posts: 1
I am a new java programmer. I have facing the problem how to store >4kb unicode data to my oracle8i database in nclob datatype, when i try to use the following statement:
String query = "INSERT INTO CHINESE (" +
"id, b" +
") VALUES (1, n'" + temp + "')";
ResultSet uprs = stmt.executeQuery(query);
where temp is a string and containt the unicode data >4kb. But if i use that statement to insert 'temp' in < than 4kb that is no problem, and the result also can select out from database by JDBC.
I also try in convert the string 'temp' to clob data insite the java program for the following insert statement, but i do not know how to convert and do not know wherever this is the correct way or not.:
OraclePreparedStatement ops = (OraclePreparedStatement)con.prepareStatement
ops.setInt(1, 9);
ops.setCLOB(2, oClob);
This statement can run, but the data inserted for the b fied in database is empty because the oClob is empty. So, have somebody know how to convert the string 'temp' to oClob?
Also, have some body know how to solve one of these problems please give a help. Thanks
I agree. Here's the link:
subject: store unicode
It's not a secret anymore!