Skip to Content.
Sympa Menu

freetds - Re: CallableStatement - setString method

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bob Kline <bkline AT rksystems.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: CallableStatement - setString method
  • Date: Wed, 11 Jul 2001 18:17:06 -0400 (EDT)


On Wed, 11 Jul 2001, Sean wrote:

> 1. Information:
> (1)We are using the latest freetds_jdbc_snapshot.jar dated 03/08/2001.
> (2)The version of the TDS protocol: not specified, therefore defaults to
> TDS 4.2., also tried setting version to 7.0 in the URL
> (3)The version of the JVM: 1.2.2
> (4)DBMS: SQL Server 7.0, Platform: WinNT(4.0) Server.
> (5)Client machine: Redhat 7.1. Web Server: tomcat 3.2.

I cannot reproduce your problem. The differences between your setup and
mine (at least the ones I can tell -- you didn't, for example, tell us
the patch level of your SQL Server) are as follows:

* JVM 1.3.0 instead of 1.2.2
* Server running on W2K instead of NT4
* Running Java code directly, instead of through tomcat

You didn't provide the source for your stored procedure, so I made up
a tiny one.

$ cat sp_ValidateUser.sql
CREATE PROC sp_ValidateUser
@arg VARCHAR(32)
AS
SELECT 'Foo ' + @arg + ' Bar'

The only differences between my test code and yours (other than the
obviously different connection info) are:

* I supplied the missing '}' in the call string.
* I'm using a string variable instead of a constant
* I'm retrieving the result column by position instead of name

$ cat tproc.java
import java.sql.*;

public class tproc {
static public void main(String args[])
throws SQLException, java.lang.ClassNotFoundException,
java.lang.Exception {

String arg = args.length > 0 ? args[0] : "mumble";
Class.forName("com.internetcds.jdbc.tds.Driver").newInstance();
Connection conn =
DriverManager.getConnection(
"jdbc:freetds:sqlserver://xxxxxx:1433/xxxxx",
"xxxxx", "xxxxx");
CallableStatement stmt =
conn.prepareCall("{ sp_ValidateUser(?) }");
stmt.setString(1, arg);
ResultSet rs = stmt.executeQuery();
rs.next();
System.out.println("ID: " + rs.getString(1));
}
}
$ javac tproc.java
$ java tproc
ID: Foo mumble Bar
$ java tproc "but not"
ID: Foo but not Bar

Leaving off the missing '}' doesn't seem to matter. Using a string
constant instead of a variable can't possibly matter, unless there's an
unbielievably bizarre bug in the JVM.

1. What happens when you replace your stored procedure with mine
(retrieving the result column by position instead of name)?

2. What happens if you run directly from the shell, instead of through
tomcat?

3. What happens (running against your own stored procedure) when you
test the return value from rs.next()?

--
Bob Kline
mailto:bkline AT rksystems.com
http://www.rksystems.com





Archive powered by MHonArc 2.6.24.

Top of Page