aspose file tools*
The moose likes JDBC and the fly likes Java JDBC PL/SQL Example Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java JDBC PL/SQL Example Request" Watch "Java JDBC PL/SQL Example Request" New topic
Author

Java JDBC PL/SQL Example Request

Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I looking for a java jdbc pl/sql example.
TIA, monty6
------------------
We learn more from our mistake's than from our success's.


Multi Platform Database Developer & DBA on E.S.T.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I use JDBC with PL/SQL on Oracle 7 from time to time. Mostly you just build the PL/SQL as if it were SQL and send it using "executeQuery". What part of the process are you interested in?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I'm presently coding a gateway appliation using PRO*C C and
Oracle 8i.
I want to code the same gateway system in JAVA. Presently I am teaching myself pl/sql. I was wondering how hard it would be to exec pl/sql from within java using the oracle thin client driver.
My plan is to run the application on my NT box. Connecting to a UNIX box running Oracle.
I have already coded a sample application using the oracle thin client. I do not have any problem there using standard sql.
If you have a small sample program that you could post.. it would be greatly appreciated.
TIA, monty6

------------------
We learn more from our mistake's than from our success's.
ram menon
Greenhorn

Joined: Oct 24, 2000
Posts: 5
Hi,
This program calls a PL/SQL stored procedure which has got an OUT paramater. As U can see it is very simple to call PL/SQL from java.
import java.sql.*;
class PLSQL
{
public static void main (String args [])
throws SQLException, ClassNotFoundException
{
// Load the driver
Class.forName ("oracle.jdbc.driver.OracleDriver");
// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection ("jdbc racle ci8:@", "scott", "tiger");

// Call a procedure with an OUT parameter
{
CallableStatement procout = conn.prepareCall ("begin my_proc(?); end;");
procout.registerOutParameter (1, java.sql.Types.BIGINT);
procout.execute();
System.out.println ("Out argument is: " + procout.getLong(1));
}

// Close the connection
conn.close();
}
}

Hope this helps,
Ram
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
thanks you this is what i was looking for...
------------------
We learn more from our mistake's than from our success's.
a.k.a. monty6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java JDBC PL/SQL Example Request