syntax for jdbc callable statement with MSSQL
Jonathan.Patton at channelmaxinc.com
Jonathan.Patton at channelmaxinc.com
Fri Mar 30 15:53:14 EST 2001
Hi,
I have been trying to use the jdbc callable statement with MSSQL and have not gotten it to work.
I have the following stored procedure in sql server:
CREATE PROCEDURE estore_view_item_sizes
@item_id varchar(50)
AS
SELECT
*
FROM store_products_sizes INNER JOIN
store_products_sizes_lookup ON
store_products_sizes.item_size_id = store_products_sizes_lookup.item_size_id
WHERE
store_products_sizes.item_id = @item_id;
and I am using the following code:
CallableStatement cs = connection.prepareCall("estore_view_item_sizes ?");
cs.setString(1, item_id);
resultSet = cs.executeQuery();
where item_id is a String passed into my method. When the code runs I get:
----------------------------------------------------
java.lang.NullPointerException
at com.internetcds.jdbc.tds.Tds.executeProcedure(Tds.java:2594)
at com.internetcds.jdbc.tds.PreparedStatement_base.executeCall(PreparedStatement_base.java:199)
at com.internetcds.jdbc.tds.CallableStatement_base.execute(CallableStatement_base.java:394)
at
com.internetcds.jdbc.tds.PreparedStatement_base.executeQuery(PreparedStatement_base.java:320)
at DataConnect.createTableDataSPStringParameter(DataConnect.java:208)
Line 208 is resultSet = cs.executeQuery();
If I don't use the tds driver and try to use the jdbc:odbc driver I get:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near
'estore_view_item_sizes'.
More information about the FreeTDS
mailing list