
SQL server jdbc driver issues with UTF8 and NVARCHAR
Hello,
I'm trying to internationalize a sqlserver 2000 db including support for
japanese text.
I have a table with 'NVARCHAR' type for unicode data.
I have changed the encoding on JSP pages to UTF8.
Having trouble passing japanese text from a webpage to the db through the
driver.
CallableStatement stmt = con.prepareCall("{call usp_japinstest(?,?) }");
stmt.setObject(1,request.getParameter("japanese"));
stmt.setObject(2,request.getParameter("english"));
This will insert the text from textfields on the page to a table in the db.
However, something is breaking on the way to the db, because when i view the
data in SQLserver, I can see that the format is different than if I entered
it directly through enterprise manager.
When I retrieve it and display in the web browser, it does not display
properly.
If I directly insert unicode data through enterprise manager, it displays
fine in the web page.
Also, if I pass in data directly to the procedure instead of calling
'setObject' or 'setString', this also works.
for example:
CallableStatement stmt = con.prepareCall("{call usp_japinstest(
request.getParameter("japanese") ,
request.getParameter("english") ) }");
this will work as far as getting data into the db in the right format and
displaying properly upon retrieval, however, i think its kind of a hack.
I would much rather use placeholders (?) with the setObject or setString
methods.
In reading the java api, it looks like there is no NVARCHAR type in
java.sql.Types and maybe the driver is converting to VARCHAR on the way into
the db??? could this be breaking the encoding?
any feedback is greatly appreciated.
Im currently setting up another machine with oracle db and oracle jdbc
driver to see if i encounter similar issues but would really like to avoid a
migration to oracle over jdbc driver issues.
thanks in advance
bob