Hi
I have few questions from Java stored Procedure and PreparedStatemnt .
As we know whenever executing some query in Java(JDBC) code, there four steps are involved :
1.parse the incoming SQL query
2.compile the query
3.plan/optimize the data acquisition path
4.execute the query
While using PreparedStatement, first time thes all steps gets executed. But, the 4th steps gets executed from next time onwards; and hence it is faster.
Q1)
But, what happens in case of StoredProcedure which we call by using CallableStatement ? Are these four steps involved in CallableStatement also ? Whether, similar to PreparedStatement, only the 4th step gets executed from second time onwards?
Q2)
Performancewise, which one we can judge as faster ?
Is it the right criteria to select either PreparedStement or CallableStatement (StoreProcedure) (?):->
When the query is simple, use PreparedStatement; and when the query is complex (doing multiple operations in one go) use StoredProcedure ().
Q3)
Do these both (PreparedStatement & StoredProcedure) gets stored ins DataBase side ; or in Java. I believe there is no any place in Java to get it stored. So is it stored in DataBase or in any WebServer (if it is running on webserver) ?
I would highly appreciate if any one can help to clearly understand the practical use and difference in StoredProcesure and PreparedStatement.
Regard,
[ September 17, 2008: Message edited by: marlajee Borstone ]
I have few questions from Java stored Procedure and PreparedStatemnt .
As we know whenever executing some query in Java(JDBC) code, there four steps are involved :
1.parse the incoming SQL query
2.compile the query
3.plan/optimize the data acquisition path
4.execute the query
While using PreparedStatement, first time thes all steps gets executed. But, the 4th steps gets executed from next time onwards; and hence it is faster.
Q1)
But, what happens in case of StoredProcedure which we call by using CallableStatement ? Are these four steps involved in CallableStatement also ? Whether, similar to PreparedStatement, only the 4th step gets executed from second time onwards?
Q2)
Performancewise, which one we can judge as faster ?
Is it the right criteria to select either PreparedStement or CallableStatement (StoreProcedure) (?):->
When the query is simple, use PreparedStatement; and when the query is complex (doing multiple operations in one go) use StoredProcedure ().
Q3)
Do these both (PreparedStatement & StoredProcedure) gets stored ins DataBase side ; or in Java. I believe there is no any place in Java to get it stored. So is it stored in DataBase or in any WebServer (if it is running on webserver) ?
I would highly appreciate if any one can help to clearly understand the practical use and difference in StoredProcesure and PreparedStatement.
Regard,
[ September 17, 2008: Message edited by: marlajee Borstone ]