File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes calling stored proc just won't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "calling stored proc just won Watch "calling stored proc just won New topic

calling stored proc just won't work

Bill Ross

Joined: Dec 20, 2000
Posts: 4
Hi All,
I am trying to call a system stored proc from SQL Server 7.0 in order to set the Truncate log on checkpoint to a value set by the user. I am this close to getting it <bill holds his thumb and index finger really close together> but can't seem to get it to run. It keeps throwing an exception.
Here are the details:
This statement works perfect when run directly against the SQL Server database using a query tool (MS Query Analyzer):
sp_dboption 'pubs', 'trunc', 'false'
WHERE 'pubs' is the database name.
This also works:
sp_dboption pubs, trunc, false
ALL PARAMETERS are nvarchar

This is the Java JDBC statement I am trying to run:

CallableStatement cs = con.prepareCall("{call sp_dboption(?, ?, ?)}");
cs.setString(1, theData.getDatabaseName());
cs.setString(2, "trunc");
cs.setString(3, this.isTruncateLog());
This is the error message thrown:
[MERANT][SQLServer JDBC Driver][SQLServer]Usage: sp_dboption [dbname [,optname [,'true' | 'false']]]

Can anyone help me out here. I have been 'playing' with it a good part of the afternoon trying to solve this, and I am about to look like the 'Bad Day' guy kicking his monitor across the room.
Any help would be greatly appreciated.

I agree. Here's the link:
subject: calling stored proc just won't work
It's not a secret anymore!