Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5364C11C22 for ; Thu, 11 Sep 2014 00:22:34 +0000 (UTC) Received: (qmail 17179 invoked by uid 500); 11 Sep 2014 00:22:34 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 17085 invoked by uid 500); 11 Sep 2014 00:22:34 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 17072 invoked by uid 99); 11 Sep 2014 00:22:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 00:22:34 +0000 Date: Thu, 11 Sep 2014 00:22:34 +0000 (UTC) From: "Raymond DeCampo (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DBUTILS-50) Support CallableStatement "out" parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DBUTILS-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Raymond DeCampo updated DBUTILS-50: ----------------------------------- Attachment: DBUTILS-50.patch Implementation of the desired functionality which (I hope) stays true to the dbutils project as much as possible. Essentially adds a class representing OUT parameters allowing users to intermix them with the list of parameters for the SQL statement. Added execute() methods to QueryRunner, which use CallableStatements and handle the OUT parameters; one flavor for procedures returning one or more result sets and one for procedures returning update counts. Unit tests are included. > 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 getOutParameters(CallableStatement stmt, Class 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)