100分!关于怎么封装Jdbc连接oracle存储过程

zdnetchina 2005-03-07 12:10:17
对存储过程不熟,请帮帮忙!
...全文
170 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zdnetchina 2005-03-13
thank you !

try.......
回复
yyjianjun 2005-03-10
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;
}
回复
yyjianjun 2005-03-10
CallableStatement cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }");

其中: Connection conn;
"REPORT_EFFORT_SUMMARY " 是我的存储过程名
回复
zdnetchina 2005-03-09
up
回复
zdnetchina 2005-03-07
就是原来用sql封装好的Bean不用改
回复
hotenM 2005-03-07
跟执行select语句一样
回复
hlsps 2005-03-07
up
回复
相关推荐
发帖
Java EE
创建于2007-09-28

6.6w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2005-03-07 12:10
社区公告
暂无公告