File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Reading NVarChar2 from Oracle 10g database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading NVarChar2 from Oracle 10g database" Watch "Reading NVarChar2 from Oracle 10g database" New topic
Author

Reading NVarChar2 from Oracle 10g database

Chris Mack
Greenhorn

Joined: Feb 24, 2009
Posts: 13
I have a table with a field that is an NVarChar2 data type in an Oracle 10g database.
I am using a Java ResultSet to get the value out:
ResultSet rs = preparedStatement.executeQuery();
String s = rs.getString("column_name");

I now want to convert the characters of the string to UTF-8.

I have tried the following:

String utf8 = new String(s.getBytes("UTF-8"));

String utf8 = new String(s.getBytes("UTF-8"),"UTF-8");

String unicode= new String(s.getBytes("UTF-16");
String utf8 = new String(unicode.getBytes("UTF-8"));

and other variations of.

I have also tried getting the value out of the result set as a byte array and tried the same type of conversions as above. I still do not get the correct characters.
I also tried some of the other character encodings supported by Oracle, but I get java.io.UnsupportedEncodingException.

Does anyone know how to read an NVarChar out of an Oracle 10g database and convert it to UTF-8?

Any help would be appreciated!

Thanks,

Chris





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading NVarChar2 from Oracle 10g database
 
Similar Threads
Problem converting form data to UTF-8 on solaris
Inserting Japanese text into Oracle database
Output French Characters to a file
utf8 to unicode..from browser to oracle db
MySQL and reading non-English characters in UTF-8