|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
hi there, i'm having a real problem here.
I have some foreign language encoded characters in the database. They are those characters that makes no sense when using the wrong charset to view them. Now I need to retrieve them from the database and re-insert as unicode so that they can be viewed properly. Now the problem is this: when I retrieve them from the database using java, some characters tend to contain single quote (') or brackets in there, thus screwing up my whole update statement. Below is the coding I am using. It works when there isn't any single quotes or brackets. Connection con = db.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select b.en_transID, b.trans_content from translations a, en_translations b where a.en_transID=b.en_transID and a.language_ID='3'"); while (rs.next()) { String original = rs.getString("En_transID"); byte bytes[] = rs.getBytes("trans_content"); if (bytes != null) { String s = new String(bytes, "UTF-16LE"); s = new String(s.getBytes(), "big5"); Statement tempStmt = con.createStatement(); tempStmt.executeUpdate("update En_Translations set trans_content = (N'"+s+"') where En_transID = '"+original+"'"); tempStmt.close(); } Is there any way to get around this? Please help! Will appreciate it very much! |
|
#2
|
|||
|
|||
|
I forgot to add. This is one of the errors that happened to me. Coz I always print out my sql statements to check for errors.
update En_Translations set trans_content = (N'(???????????????,??'?')') where En_transID = '733' |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Problem inserting foreign languages into ms sql using java |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|