CallableStmtDemo.java :
public class CallableStmtDemo {
public static void main(String[] args) {
callSpWithoutOutParam();
}
public static void callSpWithoutOutParam(){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.
getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
CallableStatement callStmt=conn.prepareCall("{call insert_stu(?,?,?,?)}");
callStmt.setInt(1,2);
callStmt.setString(2,"tom");
callStmt.setInt(3,20);
callStmt.setString(4,"M");
callStmt.execute();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}