aspose file tools*
The moose likes JDBC and the fly likes SQLException:Parameter Index 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 "SQLException:Parameter Index out of Range" Watch "SQLException:Parameter Index out of Range" New topic
Author

SQLException:Parameter Index out of Range

Swapna Gouri Kalanidhi
Ranch Hand

Joined: Mar 14, 2008
Posts: 107
Hi All
I'm getting a SQLException with description "Parameter Index out of range(1) number of parameters, which is (0).

Here's the code:


And the stack trace:


Why do I get this exception and where is the error in my code? Any help would be much appreciated...


Thanks & Regards
Swapna Gouri
I "try", I "catch" and "finally" WIN !!!
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1478
    
    6

Few mistakes in the code, those I could trace, as per your sql query there is no unknown parameters,
so I did not understand the use of pstmt.setString methods(so one cause of indexoutofbounds is happening here)
Secondly as per your query you are selecting only qtyoforder, but in the rs.next loop,
you are calling getString("customername")(one more cause of error)


Swastik
Swapna Gouri Kalanidhi
Ranch Hand

Joined: Mar 14, 2008
Posts: 107
Thank you Swastik, it's working after modification... !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException:Parameter Index out of Range