remove the single qoutes around the question marks (binds)! in the values
part of your query string.


Leon

-----Original Message-----
From: Andy C [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 29, 2001 11:36 AM
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

Reply via email to