File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid argument: parameter index 1 is out of range

 
Sudipen Maggi
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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.... :-)
 
Scott Selikoff
author
Saloon Keeper
Posts: 3896
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post the code that defines the setting constants?
 
Sudipen Maggi
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell why and in what circunstances this error comes...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic