How do I access MySQL from a web application?
Author: Deron Eriksson
Description: This Java tutorial describes using JNDI to access MySQL in a web application.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1 || Tomcat 5.5.20 || MySQL 5.0.27

Page: < 1 2 3 >

(Continued from page 1)


Next, we need to specify in our application's web.xmlW file that we want to utilize the data source specified in our server.xml file. We can do this by adding a <resource-ref> entry to web.xml. An example of this is shown below.

Resource-ref entry from the web application's web.xml:
		<description>Test DB</description>

The name specified in <res-ref-name>, 'jdbc/TestDB', is the name of the data source specified in server.xml. This is how you tell your web application about the databaseW specified in server.xml.

(Continued on page 3)

Page: < 1 2 3 >