aspose file tools*
The moose likes JDBC and the fly likes Invalid argument: parameter index 1 is out of range Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Invalid argument: parameter index 1 is out of range" Watch "Invalid argument: parameter index 1 is out of range" New topic
Author

Invalid argument: parameter index 1 is out of range

Sudipen Maggi
Greenhorn

Joined: Oct 19, 2006
Posts: 7
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.... :-)


Too many people in the world are looking for the right person, instead of being the right person.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Could you post the code that defines the setting constants?


My Blog: Down Home Country Coding with Scott Selikoff
Sudipen Maggi
Greenhorn

Joined: Oct 19, 2006
Posts: 7
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

Joined: Oct 19, 2006
Posts: 7
Can anyone tell why and in what circunstances this error comes...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

Sudipen,
Does it fail on the prepared statement or result set code? The prepared statement part looks right.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sudipen Maggi
Greenhorn

Joined: Oct 19, 2006
Posts: 7
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

Joined: Oct 19, 2006
Posts: 7
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invalid argument: parameter index 1 is out of range