Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while inserting data in database using jsp

 
laura xhaferaj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I am trying to insert some data in my database using jsp. I have already created register.jsp and insert.jsp. But what i get while click add button after have put some data is this error


register.jsp

</html>

insert.jsp
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laura,
It looks like one of those fields is being submitted empty. Do you have any validations?

Also, two pieces of advice:
1) It's considered bad practice to have JDBC (or any Java code really) in a JSP. Search for MVC to read more on this.
2) It's better to use a PreparedStatement rather than a Statement. The code is easier to read and you don't have to worry about SQL Injection.
 
laura xhaferaj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even when i put data and click insert (shto in my language) it gives me the same error is seems like ID is not an integer or something like that. When i create my form should i put type="number" instead of "text" for id?

I am new at jsp and this is the only way because i got a problem when using only Java to create connectionManager, DatabaseObject..
 
laura xhaferaj
Greenhorn
Posts: 19
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right i was putting at id (which is integer) a string o.O
Thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear you got it working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic