Font Awesome Icons
Tutorial
Menu
Core Java
AWT
Swing
Servlet
JSP
JDBC
Spring
Hibernate
JAVA JDBC
JDBC Introduction
JDBC Driver
DB Connectivity Steps
Connectivity with Oracle
Connectivity with MySQL
DriverManager
Connection
Statements
ResultSet
PreparedStatement
Store image
Retrieve image
Store file
Retrieve file
CallableStatement
Transaction Management
JDBC Basic Query
JAVA JDBC
JDBC Introduction
JDBC Driver
DB Connectivity Steps
Connectivity with Oracle
Connectivity with MySQL
DriverManager
Connection
Statements
ResultSet
PreparedStatement
Store image
Retrieve image
Store file
Retrieve file
CallableStatement
Transaction Management
JDBC Basic Query
CollableStatement
CallableStatement Interface
To call the stored procedures and functions, CallableStatement interface is used.
to get the instance of CallableStatement
public CallableStatement prepareCall(“{ call procedurename(?,?…?)}”);
Example to get the instance of CallableStatement
CallableStatement stmt=con.prepareCall(“{call myprocedure(?,?)}”);
Example to call the stored procedure using JDBC
To call the stored procedure, we need to create it in the database.
create or replace procedure “INSERTR”
(id IN NUMBER,
name IN VARCHAR2)
is
begin
insert into user420 values(id,name);
end;
/
Example:-
import java.sql.*;
public class Proc
{
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”,”oracle”);
CallableStatement stmt=con.prepareCall(“{call insertR(?,?)}”);
stmt.setInt(1,1011);
stmt.setString(2,”Alok”);
stmt.execute();
System.out.println(“success”);
}
}
Hi, Welcome to etechvidya
Home
About Us
Tutorial