Categories
Java SQL Server

Sending null values as parameters into a SQLServer stored procedure using JDBC

When calling a SQL Server stored procedure using JDBC’s CallableStatement object one uses its setXXX methods to set input parameters. XXX is the name of the type the input parameter is assumed to be of.
SQL Server does not support the setNull() method, throwing this exception:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC] The specified SQL type is not supported by this driver.

One way we went around this unpleasantry was to instead set the null value to be a different type, so instead of
setNull(position, variable)

There is an entry in the SQL Server JDBC newsgroup about this issue.
we create a new null String object and then call:
setString(position, nullString)

Share
Categories
Java SQL Server

SQL Server 2000 with Tomcat

My page on creating a DataSource in Tomcat with SQL Server 2000

Share
Share