A very simple way for connecting MySQL

  • Make a lib names folder inside WEB-INF folder of your project.
  • Go to Download This MySQL connector  .JAR file    and download it.
  • Place the above downloaded jar file inside the lib folder which is created in step 1.
  • now place your servlet's classes file into classes folder.
  • place web.xml file of your project into WEB-INF folder.
  • Run tomcate and enter your project's running URL.
  • Process completed.



Connection to Mysql Database and Run servlet action with database


2.extract this jar file wheather with the help of  command prompt or with the help of  RAR zip extractor.
3.After extracting mysql connector jar file,we will find three folder
·         Com
·         META-INF
·         org
 5.Copy com  folder .
6. Paste above copied folder into the classes folder of your project’s WEB-INF folder.
7. Now  we are  connected with Mysql database.
8.write your servlet program importing sql package.
Include in this program points  given below  or make then import a package of  confgiration of points given below  then import:
a.  use of class.forName() method
b. use of getConnection() of the DriverManager class.
c.use of createStatement,excuteUpdate,etc….
9.compile your  servlet program.
10.copy the classes  files.
11.paste those  into the classes folder of project’s WEB-INF folder .
12.make web.xml file
13.run tomcat.
14.enter your URL as localhost:potnumberas 8080/application folder name/url of main servlet file which is included in web.xml file of project
e.g.    http://localhost:8080/di/DataInsertion
15.Process completed


Counters