CallableStatement Interface PDF
CallableStatement Interface PDF
Javatpoint
Home Core Java Servlet
Comment
Forum
Basics of Java OOPs Concepts String Handling Exception Handling Nested Classes Multithreading Synchronization I/O Serialization Networking AWT Event Handling Swing LayoutManager Applet Reflection API Collection JDBC JDBC Introduction JDBC Driver Steps to connect to the database Connectivity with Oracle Connectivity with MySQL Connectivity with Access without DSN DriverManager Connection interface Statement interface ResultSet interface PreparedStatement ResultSetMetaData DatabaseMetaData Storing image Retrieving image Storing file Retrieving file Stored procedures and functions Transaction Management Batch Processing RowSet Interface JDBC New Features Java New Features RMI Internationalization
<<prev
next>>
create or replace procedure "INSERTR" (id IN NUMBER, name IN VARCHAR2) is begin insert into user420 values(id,name); end; /
In this example, we are going to call the stored procedure INSERTR that receives id and name as the parameter and inserts it into the table user420. Note that you need to create the user420 table as well to run this application.
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,"Amit"); stmt.execute(); System.out.println("success"); } }
create or replace function sum4 (n1 in number,n2 in number) return number is temp number(8); begin temp :=n1+n2; return temp; end; /
import java.sql.*; public class FuncSum { 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 sum4(?,?)}"); stmt.setInt(2,10); stmt.setInt(3,43); stmt.registerOutParameter(1,Types.INTEGER); stmt.execute(); System.out.println(stmt.getInt(1)); } }
<<prev
next>>
Tweet
Like
16k
Like the www.javatpoint.com on facebook / google+ / twitter / subscribe to get latest updates
Sitemap
Core Java
Servlet
JSP
Struts2
Hibernate
Spring
Android
Interview Questions
javatpoint.com is developed to provide easy and point to point learning and training in detail. Examples might be simplified to improve reading and basic und
Tutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. If there is any mistake, please mail [email protected] or [email protected]. We provide assurance of 90% interview questions. While using this site, you agree to hav accepted our terms of use and privacy policy. 2011-2013 Javatpoint. All Rights Reserved.