Connection cnn=null;
try{
Class.forName(JDBC_DRIVER);
cnn=DriverManager.getConnection(JDBC_URL,DB_USER,DB_PWD);
CallableStatement cstmt=cnn.prepareCall("{call "+p_strProcName+"}");
if(p_oParm!=null){
for(int i=0;i<p_oParm.length;i++){
cstmt.setObject(i+1,p_oParm);
}
}
cstmt.execute();
//cstmt.close(); //一定不能在这里就cstmt.close(),否则提交不完全!!!
cnn.commit();
cstmt.close();
}finally{
try{
cnn.close();
}catch(Exception ee){}
}
本文介绍了一个Java应用程序如何通过JDBC连接数据库并调用存储过程的具体实现。包括加载驱动、建立连接、准备并执行CallableStatement等步骤。
1014

被折叠的 条评论
为什么被折叠?



