Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC Stored Procedure difficulty
A copy of this was sent to nealgran_at_my-deja.com
(if that email address didn't require changing)
On Tue, 22 Jun 1999 19:52:26 GMT, you wrote:
>I am writing a java application which needs to access either Oracle, or
>SQLServer DBMS. I have type 4 drivers for each, and I have succesfully
>writen JDBC code to execute general queries using preparedStatements.
>However to access a Stored Procedure I believe I need to use a
>callableStatement.
>
>The problem is that I can access the SQLServer Stored procedure using
>the syntax:
>
>
> CallableStatement cstmt = con.prepareCall("PutWJ");
> cstmt .execute();
>where con is an established database connection, and PutWJ is the
>(parameterless) stored procedure set up in the SQLServer.
>
>The same syntax does not work for an oracle 8 server on which PutWJ was
>also established. The error returned was: 'ORA-00900: invalid SQL
>statement'. I tried various tweeks of the syntax such as :
> CallableStatement cstmt = con.prepareCall("Call PutWJ");
>but had no success.
>
You seem to be missing the {} in the call statement. Try:
CallableStatement cstmt = connection.prepareCall( "{ call PutWJ }" );
which works just fine for me. Without it -- it fails as it just passes the "call PutWJ" down to the server as is.
>If anyone could shed some light on my troubles I would appreciate it
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Jun 22 1999 - 15:55:45 CDT