Apache DBUtils - Stored Procedure

2019-04-12 14:12发布

问题:

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

回答1:

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.



回答2:

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