I think that there is no need for single quotes in the statement . . . . VALUES( '
?,?,?,?,?,? ' )
It should be VALUES(?,?,?,?,?,?).
Regards,
Paul.
-----Original Message-----
From: Andy C [SMTP:[EMAIL PROTECTED]]
Sent: 29 January 2001 10:36
To: [EMAIL PROTECTED]
Subject: ArrayIndexOutofBounds error in prepared statement
Ok,
Enviroment is winnt 2000 server,
Apache 1.3.12
Tomcat 3.2.1
mySql 3.23.28
JDBC mm.msql 2.0.4
Now, with a bean in a JSP page, the following code:
Connection tmp = PersistentConnection.getConnection();
PreparedStatement pmst=null;
String query= "INSERT INTO articles
(sectionId,authorId,pubtime,headline,summary,body) VALUES ('?,?,?,?,?,?')";
try {
pmst = tmp.prepareStatement(query);
}catch(Exception ex){
System.out.println("Can not prepare initial statement "+ex);
return;
}
try{
pmst.setInt(1,sectionId);
}catch(Exception ex){
System.out.println("Can not enter values into prepare statement
'1':");
System.out.println("Value: "+sectionId);
System.out.println("Reason: "+ex);
System.out.println("---------------------------------------------");
return;
}
Give the following error:
"Can not enter values into prepare statement '1':
Value: 2
Reason: java.lang.ArrayIndexOutOfBoundsException
---------------------------------------------"
Any ideas ? Is the code wrong ? I can't see it if it is ? Is there a
fault with the jdbc
I am unaware of ?
Any pointers appreciated.
Andy C
R2 project
http://www.r2-dvd.org
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html