Uploaded image for project: 'Commons DbUtils'
  1. Commons DbUtils
  2. DBUTILS-50

Support CallableStatement "out" parameters

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.7
    • None

    Description

      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:

      void registerOutParameters(CallableStatement stmt, int... sqlTypes)
      
      Object[] getOutParameters(CallableStatement stmt)
      
      void registerOutParameters(CallableStatement stmt, Class<?> beanClass)
      
      <T> T getOutParameters(CallableStatement stmt, Class<T> beanClass)
      

      You should be able to write code like this:

      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);
      

      Or like this:

      CallableStatement stmt = runner.prepareCall(myString);
      helper.registerOutParameters(stmt, TINYINT, DECIMAL);
      queryRunner.fillStatement(stmt, foo, bar, baz);
      stmt.executeUpdate();
      Object[] result = helper.getOutParameters(stmt);
      

      Attachments

        1. DBUTILS-50.patch
          41 kB
          Raymond DeCampo

        Issue Links

          Activity

            People

              thecarlhall Carl Franklin Hall
              dfabulich Daniel Fabulich
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: