This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes error in Insert Query using Perpared statments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error in Insert Query using Perpared statments " Watch "error in Insert Query using Perpared statments " New topic
Author

error in Insert Query using Perpared statments

sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Dear friends,
I am tring to write a query using PSTMT but it throws me this error:
SQLException: Parameter index out of range (4 > number of parameters, which is 3).
SQLState: S1009
VendorError: 0
SQLException: Parameter index out of range (4 > number of parameters, which is 3).
SQLState: S1009
VendorError: 0
SQLException: Parameter index out of range (4 > number of parameters, which is 3).
SQLState: S1009
VendorError: 0

, here is the insert code and the trigger code:
Insert Query:



and trigger code:


do you have any idea whats wrong?

Thanks!
Sahar.


Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
In your insert sql statement there exists 3 question marks(?), but you are trying to set the 4th ? as I see in your post line number 13.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error in Insert Query using Perpared statments
 
Similar Threads
reasons for error: SQLException: No operations allowed after connection closed?
closing connection?
can not insert to DB after a while!
how can I have multiple return from this method?
Retrieving image from database - getBlob?