Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to execute a procedure or function from Java Stored procedure

384397Dec 27 2002 — edited Dec 30 2002

Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?

Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.

Thanks in advance.

PS. The variable passed in function is just a dummy variable.

-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;

//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;

public class Test2{

public static String Testing(String d) {

Connection connection = null; // Database connection object

try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]

Long postings are being truncated to ~1 kB at this time.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 27 2003
Added on Dec 27 2002
3 comments
472 views