• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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: 42055
926
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: 42055
926
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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic