Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setString() passes my String to SQL Server as NVARCHAR

843854Jul 22 2003 — edited Jul 23 2003
Please 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2003
Added on Jul 22 2003
3 comments
917 views