You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Carl Hall (JIRA)" <ji...@apache.org> on 2015/04/15 18:46:59 UTC

[jira] [Commented] (DBUTILS-50) Support CallableStatement "out" parameters

    [ https://issues.apache.org/jira/browse/DBUTILS-50?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14496494#comment-14496494 ] 

Carl Hall commented on DBUTILS-50:
----------------------------------

Hey [~RayDeCampo], thanks for the extensive patch.  I'm looking through it now and hope to get back to you soon.

> Support CallableStatement "out" parameters
> ------------------------------------------
>
>                 Key: DBUTILS-50
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-50
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Dan Fabulich
>         Attachments: DBUTILS-50.patch
>
>
> Using fillStatement and the new fillStatementWithBean, you can use a CallableStatement like a PreparedStatement, retrieve its ResultSet and handle it with a ResultSetHandler.  But we don't yet support registering "out" parameters on the CallableStatement in a convenient way and retrieving them back into an object.
> DBUTILS-28 requests stored procedure support and provides a patch, but I don't like the patch.  Regardless, we really should support a few helpers like:
> {code}
> void registerOutParameters(CallableStatement stmt, int... sqlTypes)
> Object[] getOutParameters(CallableStatement stmt)
> void registerOutParameters(CallableStatement stmt, Class<?> beanClass)
> <T> T getOutParameters(CallableStatement stmt, Class<T> beanClass)
> {code}
> You should be able to write code like this:
> {code}
> CallableStatement stmt = runner.prepareCall(myString);
> helper.registerOutParameters(stmt, MyBean.class);
> queryRunner.fillStatement(stmt, foo, bar, baz);
> stmt.executeUpdate();
> MyBean bean = helper.getOutParameters(stmt, MyBean.class);
> {code}
> Or like this:
> {code}
> CallableStatement stmt = runner.prepareCall(myString);
> helper.registerOutParameters(stmt, TINYINT, DECIMAL);
> queryRunner.fillStatement(stmt, foo, bar, baz);
> stmt.executeUpdate();
> Object[] result = helper.getOutParameters(stmt);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)