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

不打扰是莪最后的温柔 提交于 2019-12-05 01:32:19

I have done a test on our application and it seems that getNString() is unnecessary with Java 6, JDBC 6, Oracle JDBC 6 drivers and Oracle 11.1.0.6.0. The test string I used was "Δ, Й, ק, ‎ م, ๗, あ, 叶, 葉, and 말", copied from http://en.wikipedia.org/wiki/Unicode.

Most of our data access is done via stored procedures. Java was able to set and retrieve the above test string correctly via setObject() and getString() (not setString() for abstraction reasons), collecting data from the interface and writing it back to the interface as expected.

Hence getString() works ok for Unicode data with Oracle 11g (like SQL Server as in the above link) so we will continue to use this rather than getNString().

If your DB uses the NVARCHAR2 datatype, it is designed to be storing multilingual data. Your program will break if any unicode data is stored in those columns. If I were you, I would move over to the getNXXX() methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!