开发者

NVARCHAR in JDK 1.5

开发者 https://www.devze.com 2023-02-28 21:56 出处:网络
I have couple of fields in oracle which is NVARCHAR and I am using Java 1.5. If I read those values as string is that oka开发者_开发百科y or is there a better approach for reading columns with NVARCHA

I have couple of fields in oracle which is NVARCHAR and I am using Java 1.5. If I read those values as string is that oka开发者_开发百科y or is there a better approach for reading columns with NVARCHAR?


Assuming you have a ResultSet named rs then this is appropriate for NVARCHAR:

String myColumn = rs.getString("my_column");

See Globalization Support for JDBC Drivers:

Oracle JDBC drivers provide globalization support by allowing you to retrieve data from or insert data into columns of the SQL CHAR and NCHAR datatypes of an Oracle9i database. Because Java strings are encoded as UTF-16 (16-bit Unicode) for JDBC programs, the target character set on the client is always UTF-16. For data stored in the CHAR, VARCHAR2, LONG, and CLOB datatypes, JDBC transparently converts the data from the database character set to UTF-16. For Unicode data stored in the NCHAR, NVARCHAR2, and NCLOB datatypes, JDBC transparently converts the data from the national character set to UTF-16.

0

精彩评论

暂无评论...
验证码 换一张
取 消