Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot write a new customer to the database

 
Ana Pan
Greenhorn
Posts: 4
Android Java
  • 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
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • 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
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic