Apache DBUtils - Stored Procedure

2019-04-12 13:50发布

Is it possible for apache dbutils library to invoke oracle stored procedures?

2条回答
神经病院院长
2楼-- · 2019-04-12 14:16

Yes as it just uses JDBC - you will need a JDBC driver for Oracle

查看更多
戒情不戒烟
3楼-- · 2019-04-12 14:31

Yes:

QueryRunner run = JDBCConnectionFactory.getQueryRunner(database);
Connection conn = run.getDataSource().getConnection();
CallableStatement cs = conn.prepareCall("{CALL procName()}");
ResultSet rs = cs.executeQuery();
JongoResultSetHandler handler = new JongoResultSetHandler(true);
return handler.handle(rs);

Here I use a QueryRunner instance to obtain its connection since this is managed by DBUtils. Take in mind closing connection, exception handling, etc.

Hope this helps.

查看更多
登录 后发表回答