• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java JDBC PL/SQL Example Request

 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looking for a java jdbc pl/sql example.
TIA, monty6
------------------
We learn more from our mistake's than from our success's.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic