aspose file tools*
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "calling stored proc just won Watch "calling stored proc just won New topic
Author

calling stored proc just won't work

Bill Ross
Greenhorn

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):
<PRE><CODE>
sp_dboption 'pubs', 'trunc', 'false'
</CODE></PRE>
WHERE 'pubs' is the database name.
This also works:
<PRE><CODE>
sp_dboption pubs, trunc, false
</CODE></PRE>
ALL PARAMETERS are nvarchar

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

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

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.
BillR
</PRE>

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling stored proc just won't work
 
Similar Threads
how to execute complex queries
Help with Resultset
Trouble executing stored procedure and getting a value back
Oracle wrong number or types of arguments...
Problem with Pl/Sql function when calling in java