java调用oracle函数

今天写了个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();
}
}

posted @ 2016-11-02 18:35  J-LONG  阅读(1180)  评论(2编辑  收藏  举报