GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  JDBC
Go To First  |  Previous Question  |  Next Question 
 JDBC  |  Question 131 of 135    Print  
Call stored procedure in Java using CallableStatements
How can we call a stored procedure in Java using CallableStatements? Give an example.


  
Total Answers and Comments: 1 Last Update: July 03, 2008     Asked by: khadarzone 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 03, 2008 00:03:15   #1  
pradeepkmr18 Member Since: June 2008   Contribution: 25    

RE: Call stored procedure in Java using CallableStatements

first get connection object
Connection con=DriverManager.getConnection(); (we can get by datasourse object also)
CallableStatement cstmt=con.prepareCall("{ call procedurename(?,?,?,?) }");

cstmt.setString(1,ID);
cstmt.setString(2,name);
....
ucount=cstmt.executeUpdate();

 
Is this answer useful? Yes | No

 Related Questions

Answered by Jey on 2005-05-10 05:53:50: 1.Statement which is used to run simple sql statements like select and update 2. PrepareStatment is used to run Pre compiled sql.  3. CallableStatement 
Latest Answer : Load the driver class using class.forName(driverclass) and class.forName() loads the driver class and passes the control to DriverManager class ...

Latest Answer : Stored procedure contains set of sQL Statements thar are executed in the database by the sql stament processor.code:DECLARE NUM1 NUMBER:=10; NUM2 NUMBER:=20;BEGIN    DBMS_OUTPUT.PUT_LINE('sum:'||To_Char(NUM1+NUM2,'999.99'));END; ...

Answered by Jey Ramasamy on 2005-05-10 05:50:07: Class.forName() is used to load the Driver class which is used to connect the application with Database. Here Driver class is a Java class provided by Database 
Latest Answer : Class.forName is used to create an instance of the driver and register with the DriverManager. ...

JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a different database engine and to write to a single API. JDBC allows you to write database applications 
Latest Answer : JDBC is a core API of Java 1.1 and later which provides a standard set of interfaces to SQL-compliant databases. ...

The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendors driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, 
Latest Answer : As has been mentioned above, the implementations are provided by the database vendors like for example, the classes12.jar of oracle which has the implementations. ...

There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData. 
Latest Answer : Packages arejava.sql and javax.sql only..Those mentioned in the previous lists are the classes & interfaces in those packages. ...

First JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs.E.g.ResultSet 
Latest Answer : import java.sql.*;class JDBCtableread{ public static void main(String args[])throws Exception { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:dsn2";//dsn name Connection con=DriverManager.getConnection(url); ...

The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a 
Latest Answer : Stored Procedures can be called in java by using the prepareCall() method which returns a CallableStatement object.CallableStatement cs = con.prepareCall("{call Procedure_name}");ResultSet rs = cs.executeQuery(); ...

Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage 
Latest Answer : New Features of JDBC2.0To make a updateble resultset use,Resultset.CONCUR_UPDATABLE  ...

While in CallableStatament using in the oracle my procedure is return no.of columns so in java  how can i retrivbe the data and i wnat to view all data which is reetrive from my procedure


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

What are the differences between stored procedures and triggers?

Stored procedures are compiled collection of programs or SQL statements that live in the database. A stored procedure can access and modify data present in many tables. Also a stored procedure is not associated with any particular database object. But triggers are event-driven special procedures whi
 

How does the function call within function get evaluated?

Whenever we have more than one function which is called for a finite number of times then such a function gets evaluated from inside out. Let us understand this concept with an example. For instance consider a function sample called within it 4 times as given in program below: main() { int a=50;
 

How to call C header that is not provided generally by system in C++?

Headers can be called by using extern C Syntax of extern C is: extern "C" <function declaration> for example to call C functions from C++ we can write extern "C" { <function declaration> <function declaration> ...
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

XML Remote Calling Procedure

XML Remote Calling Procedure XML RPC or the XML Remote Calling Procedure is a set of compilations and implementations which allow certain programs to run on complex platforms or operating systems and allows them to make Remote Procedure calls on the Internet The Remote Procedure Calling Protocol use
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape