• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invalid argument: parameter index 1 is out of range

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am getting the following Sql Error message... "Invalid argument: parameter index 1 is out of range"

My seq statement is like this: SELECT CODE, DESCRIPTION FROM SCHEMA.CTMTORG WHERE SUBLEVELFLAG=? and GEOCODE=?

and my DAO class has the following statement..like this :
SUBLEVELFLAG="N"
pStat = connection.prepareStatement(sql);
pStat.setString(SettingsConstants.ONE,SUBLEVELFLAG);
pStat.setString(SettingsConstants.TWO,geoCode.trim());
rSet = pStat.executeQuery();
while (rSet.next()) {...} rest of the code..
what may be the problem??
Thanks in advance.... :-)
 
Sudipen Maggi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the code..
public interface SettingsConstants {
/**
* Value ONE.
*/
int ONE = 1;
/**
* Value TWO.
*/
int TWO = 2;
}

actually these are constants I have defined
 
Sudipen Maggi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone tell why and in what circunstances this error comes...
 
author & internet detective
Posts: 41933
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sudipen,
Does it fail on the prepared statement or result set code? The prepared statement part looks right.
 
Sudipen Maggi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Actually the stack trace looks like this...


com.ibm.db2.jcc.a.SqlException: Invalid argument: parameter index 1 is out of range.
at com.ibm.db2.jcc.a.id.e(id.java(Inlined Compiled Code))
at com.ibm.db2.jcc.a.id.d(id.java(Inlined Compiled Code))
at com.ibm.db2.jcc.a.id.b(id.java(Compiled Code))
at com.ibm.db2.jcc.a.id.setString(id.java(Compiled Code))
at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper.psSetString(InternalGenericDataStoreHelper.java(Compiled Code))
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.setString(WSJdbcPreparedStatement.java(Compiled Code))
at com.ibm.services.epricer.settings.managegeocountries.dao.SQLOrganization.getAllCountriesFromORGForGeo(SQLOrganization.java:58)
at


Thanks...
 
Sudipen Maggi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Continueing from the above post...

at com.ibm.services.epricer.settings.managegeocountries.dao.SQLOrganization.getAllCountriesFromORGForGeo(SQLOrganization.java:58)


at line 58 of SQLOrganization.java..I have this line...

pStat.setString(SettingsConstants.ONE,SUBLEVELFLAG);

where the SUBLEVELFLAG = "N"

Thanks again
 
Jeanne Boyarsky
author & internet detective
Posts: 41933
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sudipen,
The only thing I can think of is that "sql" is a different value than you think it is. We've verified that "1" is being passed and that it is indeed failing on the PreparedStatement.
 
catch it before it slithers away! Oh wait, it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic