Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

store unicode

 
teo peng
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai;
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);
uprs.close();
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
("INSERT INTO CHINESE (id, b) VALUES(?,?)");
ops.setInt(1, 9);
ops.setCLOB(2, oClob);
ops.execute();
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic