If you import data with the Import Tool into a SQL Server table with NVARCHAR column using the BATCH option, it will fail. See attached screenshot.
If you import with FULL option it will work.
The exception is failing on the method call PreparedStatement.setNString() in the jTDS driver :
https://docs.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setNString(int,%20java.lang.String)
https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setNString(int,%20java.lang.String)
https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#setNString(int,%20java.lang.String)
Doing a search for "getNString" in the source code for jTDS in net.sourceforge.jtds.jdbc.JtdsPreparedStatement.java and JtdsStatement.java does not yield a result. This would cause the exception above, but it is odd that the method doesn't exists since the method is part of the JDBC API and part of the PreparedStatement interface.
Also, notice in ImportThread line 1225 we specifically don't call PreparedStatement.setNString() for Netezza, while we do for all others. (issue #11400)
Here is a StackOverflow thread on the topic :
http://stackoverflow.com/questions/12575194/jtds-jdbc-driver-getnstring-throws-error
|
114 KB
|
55 KB
@tom: try the same fix as for #11400. Be sure to test w/ inserting unicode data. However, from the stackoverflow post, it seems this user was not successful in using setString() to insert Unicode data:
EDIT 3
I changed my code to use a prepared statement in each method instead of trying to use a batch and used the setInt, setString, etc methods. However, I am still having the same problems... if I use setString() for unicode, it inserts ??? into my db. If I use setNString() then I get the same error that I received at the top of this post when I was doing getNString... This is insane... how could this driver become so popular if it doesn't actually support unicode?? What am I missing here? The site does say it supports NVARCHAR, etc.. so what crazy unintuitive thing is it that I need to do in order to make this work???
http://stackoverflow.com/questions/12575194/jtds-jdbc-driver-getnstring-throws-error
@tom: JTDS also has a driver parameter called: sendStringParametersAsUnicode
Test the behavior w/ this parameter value on or off.
Related post: http://cephas.net/blog/2005/12/02/java-jtds-preparedstatement-and-varchar/
@tom: JTDS also has a driver parameter called: sendStringParametersAsUnicode
Test the behavior w/ this parameter value on or off.
Related post: http://cephas.net/blog/2005/12/02/java-jtds-preparedstatement-and-varchar/
svn# 51112
Hi Sachin, Setting sendStringParametersAsUnicode had no effect with either setNString or setString. I went with setString like Netezza. This looks like it is working correctly. Thanks for the info, Tom
svn# 51112
Hi Sachin, Setting sendStringParametersAsUnicode had no effect with either setNString or setString. I went with setString like Netezza. This looks like it is working correctly. Thanks for the info, Tom
fyi: Looking at the jtds source code, setNString() throws AbstractMethodError
fyi: Looking at the jtds source code, setNString() throws AbstractMethodError
Issue #14692 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build 17.0.8-4 |
No time estimate |
1 issue link |
relates to #11400
Issue #11400Import is not working for NVARCHAR and NCHAR data type in Netezza database. |
@tom: try the same fix as for #11400. Be sure to test w/ inserting unicode data. However, from the stackoverflow post, it seems this user was not successful in using setString() to insert Unicode data: