In this example we will see how to call the Stored procedure have some
in parameters,Store those values in the data base.
create Stored procedure :
create or replace procedure proctwo(pone IN number,ptwo IN number)as
begin
  insert into temp values(pone,ptwo);
end proctwo;
/
jdbc using above Stored procedure example:
import java.sql.*;
class  SP2
{
  public static void main(String[] args) throws Exception
   {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","chandru");
    System.out.println(" Connected 2 DB.....");
CallableStatement cstmt=con.prepareCall("{call proctwo(?,?)}");
    cstmt.setInt(1,12);
    cstmt.setInt(2,22);
    cstmt.execute();
    System.out.println("Executed");
   
    }
}
0 comments:
Post a Comment