• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to interact with database using servlet

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Sir,
I want to interact with database in servlet program
can you please give me an example

My task is i have to enter three fields using form namely employee_id, employee_name and employee_mobile number with a submit button
By pressing the submit button the records which i have entered in the form is to be inserted in the database please help me sir
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, create a web page with an HTML form. Then, create a servlet. Make the action of the form on the web page refer to the URL of the servlet, so that the form is submitted to the servlet. Set the method attribute of form to "POST".

In the servlet, implement a doPost() method. Use request.getParameter(...) to get the information that's in the submitted form. Use JDBC to insert the information into a database.

You can find tutorials about servlet programming or JDBC on Internet, or in a book like Head First Servlets & JSP.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!