Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002
    Posts
    1

    Unanswered: upper(?) with bind not working through jdbc

    Hi all,

    Sql Query: select id , username from table_users where username = char(upper(?))

    When the above sql query is executed from the Web
    using the jdbc connection .
    I get the following error::
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0418N A statement contains a use of a parameter marker that is not valid. SQLSTATE=42610

    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java:197)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_r eturn_code(SQLExceptionGenerator.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2 (DB2PreparedStatement.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeQ uery(DB2PreparedStatement.java, Compiled Code)



    I tried various options
    1. The binding of the "?" does not fail when used with other functions like substring etc.
    2. Also the upper/lower function runs fine when the bind is actually hardcoded eg 'sarada'

    Only when the bind "?" is used along with the combination of upper/lower function the executeQuery fails.

    Kindly help in this regard,
    Thanks,
    Sarada.

  2. #2
    Join Date
    Feb 2002
    Posts
    1

    Re: upper(?) with bind not working through jdbc

    Hi
    We have now the same problem. We found 'patch', we are using following construction:
    upper( ?||'')
    Do somebody know better solution?
    Thank you
    Mira

    Originally posted by sarada
    Hi all,

    Sql Query: select id , username from table_users where username = char(upper(?))

    When the above sql query is executed from the Web
    using the jdbc connection .
    I get the following error::
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0418N A statement contains a use of a parameter marker that is not valid. SQLSTATE=42610

    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java:197)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_r eturn_code(SQLExceptionGenerator.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2 (DB2PreparedStatement.java, Compiled Code)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeQ uery(DB2PreparedStatement.java, Compiled Code)



    I tried various options
    1. The binding of the "?" does not fail when used with other functions like substring etc.
    2. Also the upper/lower function runs fine when the bind is actually hardcoded eg 'sarada'

    Only when the bind "?" is used along with the combination of upper/lower function the executeQuery fails.

    Kindly help in this regard,
    Thanks,
    Sarada.

  3. #3
    Join Date
    Jan 2003
    Location
    RTP, NC
    Posts
    1
    Thanks for the information on passing values from java to DB2 through preparedstatements. I was not able to get any of my SQL to run. I used the ?||'' method and things are working nicely.

  4. #4
    Join Date
    Jan 2003
    Posts
    13
    How about writing
    String sql =
    "select id , username from table_users where username = ?";
    PrepareStatement pst = ...;
    String param = "some_name";

    //And when you set the parameter of the PreparedStatement:
    pst.setString(1, param.toUpperCase());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •