Should I be using JDBC getNString() instead of getString()?

We are building a Java application backed by an Oracle database that we access using JDBC (drivers ojdbc6.jar and orai18n.jar). The database schema stores text columns primarily using the NVARCHAR2 data type.

The JDBC documentation for the JDBC ResultSet says that getNString() is particularly intended for use with the NCHAR, NVARCHAR etc. data types, but at the moment we are only using getString().

This seems to work fine, so I am wondering why I should use getNString() rather than getString(). Is getString() going to start failing if non-ASCII characters are entered, or is the Oracle JDBC driver indifferent as to which method I should use?

EDIT: Seems that it may be database-dependent: SQL Server doesn't seem to mind which you use, depending on the connection parameters. Does anyone have any specific information on Oracle?

12
задан Gnat 7 May 2011 в 04:58
поделиться