• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

This servlet code is executed but cannot insert data into database .Iam using oracle database

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This isn't the right way to compare whether two String objects have the same contents. Use the equals() method of String to do that:



If you do some basic debugging I think you'll find that none of your JDBC code is ever executed.

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from the HTML outputting inside the servlet, I see three major issues, where the third one is the probable cause of your direct issue:
1) You shouldn't ignore the exception in the init method. At least print it, so it will be present in the logs. Or just wrap it in a ServletException so the servlet will fail to initialize.
2) Your code is prone to SQL injection. Use a PreparedStatement instead.
3) Don't compare Strings using == but use the equals method instead. You're comparing for instance equality, and it's very unlikely that the parameter value is exactly the same object.
 
Raghavendra ReddyI
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i knw how to execute multiple queries using single connection?
 
reply
    Bookmark Topic Watch Topic
  • New Topic