SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 24th, 2004, 08:15 PM
DanDan1985 DanDan1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 DanDan1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to DanDan1985
Post Problem inserting foreign languages into ms sql using java

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!

Reply With Quote
  #2  
Old August 24th, 2004, 08:19 PM
DanDan1985 DanDan1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 DanDan1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to DanDan1985
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'

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problem inserting foreign languages into ms sql using java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway