[jira] Created: (DBUTILS-56) QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (DBUTILS-56) QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...

JIRA jira@apache.org
QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...
-------------------------------------------------------------------------------------------

                 Key: DBUTILS-56
                 URL: https://issues.apache.org/jira/browse/DBUTILS-56
             Project: Commons DbUtils
          Issue Type: Bug
    Affects Versions: 1.2
         Environment: JDK 6
OJDBC14.JAR
Oracle 9i
            Reporter: Jeffrey Bennett


We use an Oracle 9i environment and I have recently upgraded from dbutils-1.1-dev.jar (1.1 with a necessary Oracle fix in the previous release) to dbutils 1.2.  It appears we are completely dead-in-the-water with the 1.2 release due to all QueryRunner statements blowing up at runtime.  

Example output:
Too many parameters: expected 0, was given 1 Query: SELECT count(*) FROM C1IMAN.IMAN_ADD WHERE IMAN_DOC=? Parameters: [0]

Example code:
      int macId = 0;
      final QueryRunner runner = new QueryRunner();
      final Integer ii = (Integer) runner.query(
            imanConnection,
            "SELECT count(*) "
            + "FROM C1IMAN.IMAN_ADD "
            + "WHERE MACID=?",
            new Object[] { new Long(macId) },
            new ResultSetHandler()
            {
               public Object handle(ResultSet rs) throws SQLException
               {
                  rs.next();
                  return new Integer( rs.getInt(1) );
               }
            });

===========================
I didn't see a defect issued for this yet, so am doing so.  There is some discussion of the problem here:
http://www.nabble.com/-ANNOUNCEMENT--Commons-DbUtils-1.2-released-td23335162.html

The mentioned workaround is to upgrade from ojdbc14.jar (JDK 1.4+) to ojdbc5.jar (JDK 5.0+) or ojdbc6.jar (JDK 6.0+).  I have not yet confirmed if this works, still trying to acquire those later jars and they may be an Oracle 11g only thing  (i.e. not compatible with Oracle 9i).  I do note that dbutils claims to work with JDK 1.4 and up, so a ojdbc14.jar solution ought to be devised.


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (DBUTILS-56) QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...

JIRA jira@apache.org

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

yuhl commented on DBUTILS-56:
-----------------------------

hi,i also got this problem.

i use an Oracle 9i environment  and JDK1.4,and got the same execption:
Too many parameters: expected 0, was given 2

i found the fillStatement() method in QueryRunner, remove:
--
//if (pmd.getParameterCount() < params.length) {
//            throw new SQLException("Too many parameters: expected "
//                    + pmd.getParameterCount() + ", was given " + params.length);
//        }
--
then everything is fine.

> QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...
> -------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-56
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-56
>             Project: Commons DbUtils
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: JDK 6
> OJDBC14.JAR
> Oracle 9i
>            Reporter: Jeffrey Bennett
>
> We use an Oracle 9i environment and I have recently upgraded from dbutils-1.1-dev.jar (1.1 with a necessary Oracle fix in the previous release) to dbutils 1.2.  It appears we are completely dead-in-the-water with the 1.2 release due to all QueryRunner statements blowing up at runtime.  
> Example output:
> Too many parameters: expected 0, was given 1 Query: SELECT count(*) FROM C1IMAN.IMAN_ADD WHERE IMAN_DOC=? Parameters: [0]
> Example code:
>       int macId = 0;
>       final QueryRunner runner = new QueryRunner();
>       final Integer ii = (Integer) runner.query(
>             imanConnection,
>             "SELECT count(*) "
>             + "FROM C1IMAN.IMAN_ADD "
>             + "WHERE MACID=?",
>             new Object[] { new Long(macId) },
>             new ResultSetHandler()
>             {
>                public Object handle(ResultSet rs) throws SQLException
>                {
>                   rs.next();
>                   return new Integer( rs.getInt(1) );
>                }
>             });
> ===========================
> I didn't see a defect issued for this yet, so am doing so.  There is some discussion of the problem here:
> http://www.nabble.com/-ANNOUNCEMENT--Commons-DbUtils-1.2-released-td23335162.html
> The mentioned workaround is to upgrade from ojdbc14.jar (JDK 1.4+) to ojdbc5.jar (JDK 5.0+) or ojdbc6.jar (JDK 6.0+).  I have not yet confirmed if this works, still trying to acquire those later jars and they may be an Oracle 11g only thing  (i.e. not compatible with Oracle 9i).  I do note that dbutils claims to work with JDK 1.4 and up, so a ojdbc14.jar solution ought to be devised.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (DBUTILS-56) QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

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

Julien Aymé commented on DBUTILS-56:
------------------------------------

It seems that this issue is similar to the one I encountered (as described in DBUTILS-58), in that the Oracle 9i JDBC driver has a incorrect implementation of the ParameterMetaData#getParameterCount() method : it returns 0 instead of returning the number of parameters required for the PreparedStatement.

As yuhl stated, this should be resolved by commenting this code block :
{code}
        if (pmd.getParameterCount() < params.length) {
            throw new SQLException("Too many parameters: expected "
                + pmd.getParameterCount() + ", was given " + params.length);
        }
{code}

> QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...
> -------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-56
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-56
>             Project: Commons DbUtils
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: JDK 6
> OJDBC14.JAR
> Oracle 9i
>            Reporter: Jeffrey Bennett
>
> We use an Oracle 9i environment and I have recently upgraded from dbutils-1.1-dev.jar (1.1 with a necessary Oracle fix in the previous release) to dbutils 1.2.  It appears we are completely dead-in-the-water with the 1.2 release due to all QueryRunner statements blowing up at runtime.  
> Example output:
> Too many parameters: expected 0, was given 1 Query: SELECT count(*) FROM C1IMAN.IMAN_ADD WHERE IMAN_DOC=? Parameters: [0]
> Example code:
>       int macId = 0;
>       final QueryRunner runner = new QueryRunner();
>       final Integer ii = (Integer) runner.query(
>             imanConnection,
>             "SELECT count(*) "
>             + "FROM C1IMAN.IMAN_ADD "
>             + "WHERE MACID=?",
>             new Object[] { new Long(macId) },
>             new ResultSetHandler()
>             {
>                public Object handle(ResultSet rs) throws SQLException
>                {
>                   rs.next();
>                   return new Integer( rs.getInt(1) );
>                }
>             });
> ===========================
> I didn't see a defect issued for this yet, so am doing so.  There is some discussion of the problem here:
> http://www.nabble.com/-ANNOUNCEMENT--Commons-DbUtils-1.2-released-td23335162.html
> The mentioned workaround is to upgrade from ojdbc14.jar (JDK 1.4+) to ojdbc5.jar (JDK 5.0+) or ojdbc6.jar (JDK 6.0+).  I have not yet confirmed if this works, still trying to acquire those later jars and they may be an Oracle 11g only thing  (i.e. not compatible with Oracle 9i).  I do note that dbutils claims to work with JDK 1.4 and up, so a ojdbc14.jar solution ought to be devised.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (DBUTILS-56) QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBUTILS-56?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Fabulich closed DBUTILS-56.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3

This isn't exactly fixed, but by fixing DBUTILS-58, you can now work around this issue by building your QueryRunner with pmdKnownBroken.  I think this is appropriate, because in this case, Oracle's ParameterMetaData is clearly broken.

> QueryRunner exception using Oracle: Too many parameters: expected 0, was given 1 Query: ...
> -------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-56
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-56
>             Project: Commons DbUtils
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: JDK 6
> OJDBC14.JAR
> Oracle 9i
>            Reporter: Jeffrey Bennett
>             Fix For: 1.3
>
>
> We use an Oracle 9i environment and I have recently upgraded from dbutils-1.1-dev.jar (1.1 with a necessary Oracle fix in the previous release) to dbutils 1.2.  It appears we are completely dead-in-the-water with the 1.2 release due to all QueryRunner statements blowing up at runtime.  
> Example output:
> Too many parameters: expected 0, was given 1 Query: SELECT count(*) FROM C1IMAN.IMAN_ADD WHERE IMAN_DOC=? Parameters: [0]
> Example code:
>       int macId = 0;
>       final QueryRunner runner = new QueryRunner();
>       final Integer ii = (Integer) runner.query(
>             imanConnection,
>             "SELECT count(*) "
>             + "FROM C1IMAN.IMAN_ADD "
>             + "WHERE MACID=?",
>             new Object[] { new Long(macId) },
>             new ResultSetHandler()
>             {
>                public Object handle(ResultSet rs) throws SQLException
>                {
>                   rs.next();
>                   return new Integer( rs.getInt(1) );
>                }
>             });
> ===========================
> I didn't see a defect issued for this yet, so am doing so.  There is some discussion of the problem here:
> http://www.nabble.com/-ANNOUNCEMENT--Commons-DbUtils-1.2-released-td23335162.html
> The mentioned workaround is to upgrade from ojdbc14.jar (JDK 1.4+) to ojdbc5.jar (JDK 5.0+) or ojdbc6.jar (JDK 6.0+).  I have not yet confirmed if this works, still trying to acquire those later jars and they may be an Oracle 11g only thing  (i.e. not compatible with Oracle 9i).  I do note that dbutils claims to work with JDK 1.4 and up, so a ojdbc14.jar solution ought to be devised.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.