Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How i can connect my servlet to mysql database

Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will anybody please tell me how i can connect my servlet to mysql database.
i am using jdk1.5,tomcat5 & mysql4.0.18.The installation directory for thes are as:
C:\Program Files\Java\jdk1.5.0_12
I am putting all my servlet file inside testpackage,package so the folder sequence is like :
i have created student database and it is in C:\mysql\data directory
this database contains a simple table name detail with column like roll,name,address.
Now i want to connect this table with servlet and want to display the data from this table to my browser.
Please tell me where i should place the database,what change i should make in web.xma(if it is required).
For example say if i want to connect displatRecord servlet(means, this will be inside testpackage, package) to detail table and want to display the records in browser then what should i do.
I know java connectivity with access database but i do not knoe how this can be done with servlet when i am using a local server.
Thanks to all
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You dont connect servlet to database but use jdbc for database access.
Look at this tutorial Servlet tutorial
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This page shows how to set up Tomcat's internal database connection pool.
A day job? In an office? My worst nightmare! Comfort me tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic