100分!关于怎么封装Jdbc连接oracle存储过程 就是原来用sql封装好的Bean不用改 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CallableStatement cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }");其中: Connection conn;"REPORT_EFFORT_SUMMARY " 是我的存储过程名 select 语句是用PrepareStatement , 存储过程要用CallableStatement. 给你一段代码:public void execProcedure(String subscriber, String user, Timestamp startDate, Timestamp endDate, Timestamp newVersion ) throws ETMDataAccessException { SQLConnectionManager manager = null; Connection conn = null; CallableStatement cStmt = null; boolean commit = false; try { manager = SQLConnectionManager.getInstance(); conn = manager.getConnection(); cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }"); cStmt.setTimestamp(1, startDate); cStmt.setTimestamp(2, endDate); cStmt.setString(3, subscriber); cStmt.setString(4, user); cStmt.setTimestamp(5, newVersion); boolean bRight = cStmt.execute(); //if (bRight != true) { // throw new SQLException();// } commit = true; } catch (SQLException e) { throw new ETMDataAccessException(e); } catch (ETMInitializationException e) { throw new ETMDataAccessException(e); } finally { try { if (commit) { conn.commit(); } else { conn.rollback(); } } catch (Exception e) { throw new ETMDataAccessException(e); } finally { if (cStmt != null) { try { cStmt.close(); } catch (Exception e) {} } if (manager != null) { manager.releaseConnection(conn); } } } // return commit; } 叫法 求救 !!!新手 hibernate中的lazy与fetch有什么区别 急需面试sql语句的试题 webservice返回List如何解析 Servlet出错 求助:文档解析时中文转化问题 求助:websphere 如何实现两个客户端远程协助? webService服务端如何将xml传给客户端 做j2ee,能做到几岁? Session Bean中得到ResultSet对象(内含三个字段),怎样方便的传到前台jsp中? 高手请指点指点新手啊 江湖救急
"REPORT_EFFORT_SUMMARY " 是我的存储过程名
给你一段代码:
public void execProcedure(String subscriber, String user,
Timestamp startDate, Timestamp endDate, Timestamp newVersion )
throws ETMDataAccessException { SQLConnectionManager manager = null;
Connection conn = null;
CallableStatement cStmt = null; boolean commit = false;
try {
manager = SQLConnectionManager.getInstance();
conn = manager.getConnection();
cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }");
cStmt.setTimestamp(1, startDate);
cStmt.setTimestamp(2, endDate);
cStmt.setString(3, subscriber);
cStmt.setString(4, user);
cStmt.setTimestamp(5, newVersion);
boolean bRight = cStmt.execute();
//if (bRight != true) {
// throw new SQLException();
// }
commit = true;
} catch (SQLException e) {
throw new ETMDataAccessException(e);
} catch (ETMInitializationException e) {
throw new ETMDataAccessException(e);
} finally {
try {
if (commit) {
conn.commit();
} else {
conn.rollback();
}
} catch (Exception e) {
throw new ETMDataAccessException(e);
} finally {
if (cStmt != null) {
try {
cStmt.close();
} catch (Exception e) {}
}
if (manager != null) {
manager.releaseConnection(conn);
}
}
}
// return commit;
}