java.sql.SQLException: Invalid parameter index 2.

Hibernate JIRA | Jason Stiefel | 1 decade ago
  1. 0

    Attempting to perform a simple find: from UserTransaction trans where trans.user = ? I'm passing the user with a type of Hibernate.OBJECT. The SQL generated is: [junit] Hibernate: select usertransa0_.guid as guid, usertransa0_.type as type, usertransa0_.user_guid as user_guid, user transa0_.partner_guid as partner_3_, usertransa0_.occured as occured, usertransa0_.user_active_state as user_act6_, usertrans a0_.user_timebank_adjustment as user_tim7_, usertransa0_.user_timebank_media_format as user_tim8_, usertransa0_.user_timebank _balance as user_tim9_ from AiaTransaction usertransa0_ where usertransa0_.type in (3, 2, 4, 1) and ((usertransa0_.user_guid= ? )) As you can see only a single "?" placeholder is present in the SQL. But I'm getting this exception (debug output included): [junit] 17:03:59,968 DEBUG [impl.BatcherImpl] preparing statement [junit] 17:03:59,968 DEBUG [type.ClassType] binding 'com.aebn.aia.core.domain.User' to parameter: 1 [junit] 17:03:59,968 DEBUG [util.SerializationHelper] Starting serialization of object [4028815a016e1aa901016e1ab737000e] [junit] 17:03:59,983 DEBUG [type.SerializableType] binding '2c6d8085f480a0b4b0b2b8b8b1b5e1b0b1b6e5b1e1e1b9b0b1b0b1b6e5b1e 1e2b7b3b7b0b0b0e5' to parameter: 2 [junit] 17:03:59,983 DEBUG [util.SerializationHelper] Starting serialization of object [4028815a016e1aa901016e1ab737000e] [junit] 17:03:59,999 DEBUG [util.JDBCExceptionReporter] SQL Exception [junit] java.sql.SQLException: Invalid parameter index 2. [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:239) [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:311) [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setBytes(JtdsPreparedStatement.java:468) [junit] at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) [junit] at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) [junit] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) [junit] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)

    Hibernate JIRA | 1 decade ago | Jason Stiefel
    java.sql.SQLException: Invalid parameter index 2.
  2. 0

    Attempting to perform a simple find: from UserTransaction trans where trans.user = ? I'm passing the user with a type of Hibernate.OBJECT. The SQL generated is: [junit] Hibernate: select usertransa0_.guid as guid, usertransa0_.type as type, usertransa0_.user_guid as user_guid, user transa0_.partner_guid as partner_3_, usertransa0_.occured as occured, usertransa0_.user_active_state as user_act6_, usertrans a0_.user_timebank_adjustment as user_tim7_, usertransa0_.user_timebank_media_format as user_tim8_, usertransa0_.user_timebank _balance as user_tim9_ from AiaTransaction usertransa0_ where usertransa0_.type in (3, 2, 4, 1) and ((usertransa0_.user_guid= ? )) As you can see only a single "?" placeholder is present in the SQL. But I'm getting this exception (debug output included): [junit] 17:03:59,968 DEBUG [impl.BatcherImpl] preparing statement [junit] 17:03:59,968 DEBUG [type.ClassType] binding 'com.aebn.aia.core.domain.User' to parameter: 1 [junit] 17:03:59,968 DEBUG [util.SerializationHelper] Starting serialization of object [4028815a016e1aa901016e1ab737000e] [junit] 17:03:59,983 DEBUG [type.SerializableType] binding '2c6d8085f480a0b4b0b2b8b8b1b5e1b0b1b6e5b1e1e1b9b0b1b0b1b6e5b1e 1e2b7b3b7b0b0b0e5' to parameter: 2 [junit] 17:03:59,983 DEBUG [util.SerializationHelper] Starting serialization of object [4028815a016e1aa901016e1ab737000e] [junit] 17:03:59,999 DEBUG [util.JDBCExceptionReporter] SQL Exception [junit] java.sql.SQLException: Invalid parameter index 2. [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:239) [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:311) [junit] at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setBytes(JtdsPreparedStatement.java:468) [junit] at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) [junit] at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) [junit] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) [junit] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)

    Hibernate JIRA | 1 decade ago | Jason Stiefel
    java.sql.SQLException: Invalid parameter index 2.
  3. 0

    Prepared Statement invalid parameter index

    Oracle Community | 1 decade ago | 807607
    java.sql.SQLException: Invalid parameter index 2.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GitHub comment 981#159113952

    GitHub | 1 year ago | wangyingdong
    java.sql.SQLException: Invalid parameter index 2.
  6. 0

    jTDS insert problem with JtdsPreparedStatemen

    jtds | 1 decade ago | icecuber
    java.sql.SQLException: Invalid parameter index 3.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.sql.SQLException

      Invalid parameter index 2.

      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter()
    2. jTDS
      JtdsPreparedStatement.setBytes
      1. net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:239)
      2. net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:311)
      3. net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setBytes(JtdsPreparedStatement.java:468)
      3 frames
    3. net.sf.hibernate
      NullableType.nullSafeSet
      1. net.sf.hibernate.type.BinaryType.set(BinaryType.java:28)
      2. net.sf.hibernate.type.SerializableType.set(SerializableType.java:28)
      3. net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
      4. net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
      4 frames