Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Error while inserting data in database using jsp

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 40853
831
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 40853
831
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to hear you got it working.
reply
    Bookmark Topic Watch Topic
  • New Topic