Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0CE6611334 for ; Thu, 11 Sep 2014 12:27:52 +0000 (UTC) Received: (qmail 75842 invoked by uid 500); 11 Sep 2014 12:27:51 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 75723 invoked by uid 500); 11 Sep 2014 12:27:51 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 75712 invoked by uid 99); 11 Sep 2014 12:27:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 12:27:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ray@decampo.org designates 209.85.212.171 as permitted sender) Received: from [209.85.212.171] (HELO mail-wi0-f171.google.com) (209.85.212.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 12:27:44 +0000 Received: by mail-wi0-f171.google.com with SMTP id bs8so831249wib.4 for ; Thu, 11 Sep 2014 05:27:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=gFj84WqGEmnRHxcwPuey/M6xGVrlD2NIkxK5GFOHPLE=; b=kVebP9W1ZfPi8kZZuRwI/+erC+aZiZFxjhp8Qbw+egq18c9LYpv/kxAmPDK7zG14iu WeLiNbxkul3XOaML/wrZiA/2x0XALl2DgZTHD9VC6WrdmbVvPPVnLSAoazvHzdcDUWaT wpw3URbQMxFc+ww+3Js9IMvXwnB0u29a8gAjP5wzZWjyWFmDqJK/9uMHQsRQ8CFvh4gM B0g7K06KBYPJil7kHR04kzewkVP8IYwbRuQ7YIlKAJ0T1Rd3PNX7tpjr9iMaK6G0/v9g MGEQZK6mVHE00ftm8rPk3pzRWAkfWCjZ2F+ykwdO7AGDGqa/mKQgl8tGGn9AYxTjgO3e hCjg== X-Gm-Message-State: ALoCoQlFNW08GGstFnaCtF5QsT5QDzBGBBJ+mf7dlraDvRZJ5DR+P+NSymJCyuZpUrFQA7N5ABIT MIME-Version: 1.0 X-Received: by 10.180.73.115 with SMTP id k19mr1782886wiv.35.1410438439882; Thu, 11 Sep 2014 05:27:19 -0700 (PDT) Received: by 10.216.147.69 with HTTP; Thu, 11 Sep 2014 05:27:19 -0700 (PDT) X-Originating-IP: [24.97.102.250] Date: Thu, 11 Sep 2014 08:27:19 -0400 Message-ID: Subject: [dbutils] DBUTILS-50; OUT parameters for stored procedures From: Raymond DeCampo To: dev@commons.apache.org Content-Type: multipart/alternative; boundary=f46d043749cb2fe5c60502c94a50 X-Virus-Checked: Checked by ClamAV on apache.org --f46d043749cb2fe5c60502c94a50 Content-Type: text/plain; charset=UTF-8 I have attached a patch for DBUTILS-50 which requests OUT parameters for stored procedures. My approach was to add execute() methods to QueryRunner which will use a CallableStatement to run the SQL. If any of the parameters passed are instances of OutParameter (a new class), the parameter is registered as an OUT parameter with the CallableStatement and the value is available from the OutParameter instance after the call has completed. INOUT parameters are also supported by setting a value on the OutParameter instance. There are flavors of execute() for procedures returning result sets and procedures that return update counts. For example supposed procedure my_proc takes four parameters; IN, OUT, INOUT, IN. The following example code would apply: QueryRunner runner = ... OutParameter in = new OutParameter<>(Types.INTEGER, Integer.class); OutParameter inout = new OutParameter<>(Types.VARCHAR, String.class, "input value"); runner.execute("{call my_proc(?,?,?,?)}", "value1", in, inout, 42); Integer inReturn = in.getValue(); String inoutReturn = inout.getValue(); I thought that this approach would keep to the principle of shielding the library users from the gory details of JDBC while keeping an interface consistent with the current code. Unfortunately we bend a little on the idea of keeping the user from needing to create helper objects, but something had to give. This way allows the user to interleave IN, OUT and INOUT parameters in the same set of arguments to the method keeping the method signature sane and familiar. I'd appreciate any feedback. Thanks, Ray --f46d043749cb2fe5c60502c94a50--