Commons DbUtils
  1. Commons DbUtils
  2. DBUTILS-58

QueryRunner: Allow to completly disable use of PreparedStatement#getParameterMetaData

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      MSSQL Server legacy jdbc driver

      Description

      Some legacy JDBC driver does not support the PreparedStatement#getPreparedStatementMetaData() method (see stacktrace in joined file).
      I would like to add an new boolean field (named disablePmd, set via constructors) to QueryRunner, which would completly remove the use of this method in QueryRunner#fillStatement.

              ParameterMetaData pmd = null;
              if (!disablePmd) {
                  pmd = stmt.getParameterMetaData();
                  if (pmd.getParameterCount() < params.length) {
                      throw new SQLException("Too many parameters: expected "
                              + pmd.getParameterCount() + ", was given " + params.length);
                  }
              }
      
      1. stacktrace.txt
        0.7 kB
        Julien Aymé
      2. QueryRunner.diff
        4 kB
        Julien Aymé

        Activity

        Hide
        Julien Aymé added a comment -

        The stacktrace, and the proposed patch

        Show
        Julien Aymé added a comment - The stacktrace, and the proposed patch
        Hide
        Julien Aymé added a comment -

        The exception was thrown using msbase.jar, unknown version.
        I was able to retrieve these information from com.microsoft.jdbc.base.BaseDriver.class using jad:

            public final int getMajorVersion() {
                return 2;
            }
        
            public final int getMinorVersion() {
                return 2;
            }
        
        Show
        Julien Aymé added a comment - The exception was thrown using msbase.jar, unknown version. I was able to retrieve these information from com.microsoft.jdbc.base.BaseDriver.class using jad: public final int getMajorVersion() { return 2; } public final int getMinorVersion() { return 2; }
        Hide
        Dan Fabulich added a comment -

        Fixed in revision 832257. I didn't use Julien's patch, but just opted to reuse pmdKnownBroken. If PMD is known to be broken, then we don't use it for parameter counting either.

        Show
        Dan Fabulich added a comment - Fixed in revision 832257. I didn't use Julien's patch, but just opted to reuse pmdKnownBroken. If PMD is known to be broken, then we don't use it for parameter counting either.

          People

          • Assignee:
            Unassigned
            Reporter:
            Julien Aymé
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development