Question:
What are the three statements in JDBC & differences between them?
Answer:
Statement
Represents a basic SQL statement
PreparedStatement
Represents a precompiled SQL statement, which can offer improved performance
CallableStatement
Allows JDBC programs complete access to stored procedures within the database itself
Submitted by Chakilam Kavitha ([email protected]) Source: CoolInterview.com
There are 3 types of statements used in jdbc ------ 1.createStatement() 2.preparedStatement() 3.callableStatement()
createStatement returns the object of statement.through this we can call methods belongs to the statement interface.preparedStatement returns the object of preparedstatement.through this we can call methods belongs to the preparedstatement interface.
The difference b/w statement and preparedstatement is : if we use statement the sql querry parses by the database server each and every time.when we send the request. but by using preparedstatement the sql querry parses only once and that
parsed querry is used every time.
for example if there are 100 sql statements by using statement 100 parsings are necessary. but by using preparedStatement the parsing is happened only once.so we can save the 99 parsings.
The callablestatement is used to call the storedprocedures. Source: CoolInterview.com
Answered by: p.balakrishna | Date: 5/8/2009
| Contact p.balakrishna
Statement and Prepared Statements are sql statements while Callable Statements are used for stored procedures only. The relationship between them is as"a Callable Statement(interface) extends Prepared statement(interface) and Prepared Statement in turn is a Statement(interface) Source: CoolInterview.com
Answered by: Ravi Mishra | Date: 10/3/2009
| Contact Ravi Mishra
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|