Re: help!! how to call pl/sql anonymous block from java?
- From: "Vladimir M. Zakharychev" <vladimir.zakharychev@xxxxxxxxx>
- Date: Sat, 29 Mar 2008 06:06:14 -0700 (PDT)
On Mar 29, 8:47 am, code <kevinj...@xxxxxxxxx> wrote:
I know that jdbc can call a pl/sql package or procedure,but if i
want to call a pl/sql anonymous block, how can i do it? no procedure
name or package name will be offered.
Can u give me a sample code? thanks very much
Just use a CallableStatement or OracleCallableStatement:
import java.sql.*;
import oracle.jdbc.*;
....
try
{
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@dbhost:
1521:ORCL","SCOTT","TIGER");
OracleCallableStatement oracs =
((OracleConnection)conn).prepareCall("BEGIN do_something; END;");
try
{
if (oracs.execute())
{
ResultSet rs = oracs.getResultSet();
// process the result set here
}
}
catch(SQLException ex)
{
System.out.println("Exception in execute phase: ");
ex.printStackTrace();
}
finally
{
// we want to close the statement regardless if it failed or not
oracs.close();
}
}
catch(SQLException sqlex)
{
System.out.println("General SQL exception encountered:");
sqlex.printStackTrace();
}
Hth,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
.
- Follow-Ups:
- References:
- Prev by Date: Re: any info on dates when oracle 11g patchset may be arriving?
- Next by Date: Re: 9i runInstaller hangs - AIX 5.3 ML05
- Previous by thread: Re: help!! how to call pl/sql anonymous block from java?
- Next by thread: Re: help!! how to call pl/sql anonymous block from java?
- Index(es):