Home » Developer & Programmer » JDeveloper, Java & XML » running sql script in java
running sql script in java [message #171055] Mon, 08 May 2006 02:23 Go to next message
neerajmaurya
Messages: 5
Registered: April 2006
Location: Pune, India
Junior Member

hi!

help me out again..

i have written a JSP program. which connect to oracle.

i have a procedure code

eg.

create procedure a is
begin
dbms_output.put('you r great');
end;

now what i want is to run this sql script from java as i don't want to run it in oracle databse.

plz provide me a solution.

thanks
Re: running sql script in java [message #171731 is a reply to message #171055] Thu, 11 May 2006 05:25 Go to previous message
hobbes
Messages: 173
Registered: January 2006
Senior Member
For a procedure "a" with two IN parameters (of types VARCHAR2 and NUMBER respectively) and one OUT parameter (type NUMBER), the JSP call would look like:

<% CallableStatement storedProc = conn.prepareCall("{ call a(?,?,?) }");%>
<% storedProc.registerOutParameter(3,Types.INTEGER);%>
<% storedProc.setString(1,param1); %> 
<% storedProc.setInt(2,param2); %>

<% try { storedProc.execute();
outParam = storedProc.getInt(3);} 
catch (SQLException sqlEx) { 
out.println("Error occured! ");
out.println(sqlEx.getMessage());
}%>
Previous Topic: JDeveloper navigation
Next Topic: Need to insert/update data from xml into tables.
Goto Forum:
  


Current Time: Fri Apr 26 03:26:50 CDT 2024