码迷,mamicode.com
首页 > 数据库 > 详细

java调用oracle函数

时间:2016-11-02 20:09:26      阅读:305      评论:0      收藏:0      [点我收藏+]

标签:ror   out   call   int   调用   trace   nec   cal   reg   

今天写了个oracle函数,但但对java如何调用不是很明白。

今天写了个,并且成功运行了。

Connection conn = null;
CallableStatement cstmt = null;
try {
conn = this.getJdbcTemplate().getDataSource().getConnection();
cstmt = conn.prepareCall("{call AUTO_TENDER_NVL(?)}");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setInt(1,89836);

cstmt.execute();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (cstmt != null) {
cstmt.close();
if (conn != null) {
conn.close();
}
}
} catch (SQLException e) {
System.out.println("SQL state" + e.getSQLState());
System.out.println("错误消息" + e.getMessage());
System.out.println("错误代码" + e.getErrorCode());
e.printStackTrace();
}
}

java调用oracle函数

标签:ror   out   call   int   调用   trace   nec   cal   reg   

原文地址:http://www.cnblogs.com/lijinlong/p/6024005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!