• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot write a new customer to the database

 
Ana Pan
Greenhorn
Posts: 4
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a problem with my code and hope that somebody can point me what am I doing wrong.
My program uses MVC structure. Part of it is the customer login (working), add(not working) and update(not working).

Right now, I am trying to get my addCustomer part working. When I deploy it, it gives me

java.sql.SQLException: Parameter index out of range (9 > number of parameters, which is 8)

I cannot find where I did that mistake, please help me find it.

addCustomer.html


CustomerSystem.java (controller)


Customer.java (customer class)


Thank you very much in advance for any help or advice,
Ana
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the relevant code from your post:



Your INSERT statement has 8 parameters (those question marks). They are numbered from 1 to 8. So your numbering in the setString calls is off by 1.
 
Ana Pan
Greenhorn
Posts: 4
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,
I have edited that piece of the code.
Now it looks like this:



Unfortunately, now I get

SEVERE: The log message is null.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'userName' cannot be null


for some reason it doesn't take userName info...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic