jump to navigation

CallableStatements, JdbcTemplate and jTDS October 15, 2008

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

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