jump to navigation

CallableStatements, JdbcTemplate and jTDS October 15, 2008

Posted by Phill in Data Access Layer, General J2EE, Spring.
Tags: , , , ,
trackback

I’ve been using the jTDS driver to connect to our SQL Server database. We have a stored procedure which I needed to call. In this project I would normally use iBATIS, but this particular call required the features of JdbcTemplate and CallableStatements (there are good reasons which I won’t go into now!)

The stored procedure has one out parameter, and also returns a ResultSet. I thought this would be pretty simple to set up – but all my attempts kept coming up with the error message “Could not set up parameter for remote server” (which the jTDS driver was sending back).

At the time I was using named parameters. What I’ve done is to switch to using positioned parameters (i.e. setString(1, “Parameter”); registerOutParameter(2, Types.VARCHAR)) and that has seemed to fix the problem.

A bit bizarre, but as I couldn’t find any info about this error anywhere on the internet I thought it was worth posting about in case it saves someone else a headache 🙂

Advertisements

Comments

1. Yishai - August 31, 2009

I’m working around a slightly different issue, but it may be related. jTDS requires the parameter be named with the @ sign in front of it (as it is declared in the stored procedure) rather than the MSSQL behavior which requires you to drop the @ sign (I think, or at least it doesn’t require it, for sure, in named parameters).


Sorry comments are closed for this entry

%d bloggers like this: