Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Accessing Oracle stored procedures thru JDBC

Re: Accessing Oracle stored procedures thru JDBC

From: RHC <rclarence_at_juno.com>
Date: Wed, 28 Feb 2001 20:30:07 -0000
Message-ID: <t9qnufc7albrf8@corp.supernews.com>

It definitely is, the easy was through JDBC is something like the following...

First you need to get the correct JDBC driver classes, which can be downloaded from Oracle's web site.

Then assuming you have a stored procedure that takes a number as a parameter i.e. ProcA(num IN NUMBER)

to call it in Java
I'm assuiming you have already gotten a connection object (conn), something like what follows is in order

CallableStatement call = conn.prepareCall("{call ProcA(?)}"); call.setInt(1,100);
call.execute();

if the stored procedure is a function that returns a String then do this...

CallableStatement call = conn.prepareCall("{? = call ProcA(?)}");

call.registerOutParameter(1,Types.VARCHAR);
call.setInt(2,100);
call.execute();

String x = call.getString(1);

if the procedure takes an OUT or an IN/OUT then you need to user the registerOutParameter as in the previous example.

HTH RHC lance mottley wrote:
>
> Is it possible to access Stored procedures in an Oracle DB via JDBC...if
>
> so, can someone please point me in the right direction...show tell me
> how trivial it is....
>
> thx
>
>
>
>
>

--
Posted via CNET Help.com
http://www.help.com/
Received on Wed Feb 28 2001 - 14:30:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US