有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JDK1.5中的java NVARCHAR

我在oracle中有几个字段是NVARCHAR,我使用的是Java1.5。如果我将这些值作为字符串来读取,这可以吗?或者有更好的方法使用NVARCHAR来读取列吗


共 (1) 个答案

  1. # 1 楼答案

    假设您有一个名为rsResultSet,那么这适用于NVARCHAR

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

    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.