setString() passes my String to SQL Server as NVARCHAR
843854Jul 22 2003 — edited Jul 23 2003Please forgive me if this has been asked before - I had a quick search of existing topics but couldn't find it.
My problem is that I'm searching a VARCHAR field of a table in an SQL Server 2000 database. I'm using a prepared statement and setting the parameter with setString, passing in my String. Either one or both of the JDBC driver (Microsoft's SQL Server 2000 driver) and the database have decided that this String that I'm passing in is of type NVARCHAR. This means that it has to run a conversion on this in order to compare it to the VARCHAR field and therefore can't use the index that I've set up on this column, making it terribly slow.
Is there a way I can tell it to treat my String as VARCHAR? I don't remember having this problem using Oracle. Otherwise I might have to change all my searchable VARCHAR fields to NVARCHAR.
Thanks
Stephen