Hello,
usually unicode with jdbc should work. But there are some pitfalls. In my
configuration I cannot printout real unicode characters with the method
System.out.println (...). I always get a '?' for unicode characters.
Therefor I use a helper class which printout unicode strings in a swing
frame. The attached java-file gives you an example on how you can insert,
retrieve and display unicode strings with jdbc, SAP DB and Java. I've tested
it and it works, but I don't know what's the meaning of the chinese
characters I have copied from a webpage;)

BTW: If your sql-command contains really unicode characters you must set the
connect-property  "unicode=yes"
(http://www.sapdb.org/jdbcSapdbcEng.html#Connect_Properties).

Regards,
Marco
----------------------------------------------
Marco PASKAMP
SAP DB, SAP Labs Berlin

> -----Original Message-----
> From: Marty Chiu [mailto:[EMAIL PROTECTED]]
> Sent: Montag, 10. Juni 2002 08:25
> To: [EMAIL PROTECTED]
> Subject: problem on retrieve data from unicode database
> 
> 
> I have configurated my SapDB server to support unicode
> (set _UNICODE -> YES & DEFAULT_CODE -> UNICODE). I
> tried to insert and retrieve chinese string by using
> SQL Studio successfully.
> However, I have a problem on using Java to retrieve
> this unicode data. My program code:
> 
> try {
> Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
> Connection connection = DriverManager.getConnection
> (url, user, password);
> Statement stmt = connection.createStatement ();
> ResultSet results = stmt.executeQuery ("select name
> from chinese_table");
> results.next ();
> String result_text = results.getString(1);
> System.out.println (result_text);
> } catch (UnsupportedEncodingException e) {
>           e.printStackTrace(); 
> }
> 
> I can't get the result as normal as in using SQL
> Studio. It shows un-recognized characters. Please help
> to tell me how to handle the unicode data and also how
> to insert chinese characters into unicode database by
> using Java.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> _______________________________________________
> sapdb.general mailing list
> [EMAIL PROTECTED]
> http://listserv.sap.com/mailman/listinfo/sapdb.general
> 

Attachment: ExampleUnicode.java
Description: Binary data

Reply via email to