PreparedStatment ps = null;
public void executeQueries(){
try{
ps = conn.prepareStatement(Query1);
// Execute Query1 here and do the processing.
ps = conn.prepareStatement(Query2);
// Execute Query2 here and do the processing.
//... more queries
}catch(){}
finally{
ps.close(); // At this point would the caching of queries in DB be lost?
}
}
在我的应用程序中,我经常调用方法executeQueries().
我的问题是,如果我在方法(我经常使用)中的finally块中关闭PreparedStatement,数据库系统是否会删除缓存?如果是,我可以为整个应用程序创建一个全局PreparedStatement,因为我的应用程序中有大量JAVA CLASSES查询数据库.
谢谢!
更新:问题已标记为重复,但链接的线程根本不回答我的问题. AFAIK,数据库系统将执行的查询存储在高速缓冲存储器中.它还存储了他们的执行计划.这是PreparedStatement比Statement更好的地方.但是,一旦PreparedStatement关闭,我不确定是否删除了与查询相关的信息.