Re: Stored procedures & JDBC?

From: <breuere_at_yahoo.com>
Date: 27 Apr 2001 21:39:47 GMT
Message-ID: <9ccov3$3c8$1_at_news.netmar.com>


In article <9c7irt$fgbj$1_at_as121.tel.hr>, Kresimir Musa <kresimir.musa_at_fer.hr> writes:
>I'd be thankful if someone could explain the proper way to call an Oracle
>stored procedure from Java servlet.
>I've created a procedure using Oracle DBA Studio
>(Database->Schema->Procedure->Create...). When I try to execute it from SQL
>Plus it works fine.
>When I try to invoke this procedure from my servlet using
> CallableStatement stmt = conn.createStatement("{call proc_name(?,?)}");
> stmt.execute();
>i get an SQLException saying that proc_name needs to be declared!
>
>Am I missing something here...?
>
>

You need to use the prepareCall method instead of the createStatement method. You'll also want to set the procedure arguments I.e.

    CallableStatement stmt = conn.prepareCall("{call proc_name(?,?)}");

    stmt.setObject(1, arg1);
    stmt.setObject(2, arg2);
    stmt.execute();

  • Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web ----- http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups NewsOne.Net prohibits users from posting spam. If this or other posts made through NewsOne.Net violate posting guidelines, email abuse_at_newsone.net
Received on Fri Apr 27 2001 - 23:39:47 CEST

Original text of this message