Can you explain CallableStatement interface in details?
CallableStatement Interface:
It is an interface which is the sub interface of Statement Interface. In this the queries are not written in program like in PreparedStatement interface. In this we use stored procedures for queries. Connection.prepareCall() is used to create new CallableStatement objects which can accept the IN , OUT or INOUT parameters and returns ResultSet.
For example:import java.sql.*;
class call
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:students");
Callable Statement c= con.prepareCall(“{Call insert_data(?,?)});
//set input parameters
c.setInt(1,10);
c.setString(2,”ABC”);
c.executeUpdate();
System.out.println(“Record Inserted”);
}
catch(SQLException e)
{
System.out.println(e);
}
catch(ClassNotFoundException e1)
{
System.out.println(e1);
}
}
}