Referencing Database from Context.xml

In the Context.xml file, I have reference to the database I am using for the application. Here is the Context.xml code.

<?xml version="1.0" encoding="UTF-8"?>

<Context path="ABATE" reloadable="true" docBase="C:\Documents and Settings\koconnor\EclipseWorkspace\ABATE" workDir="C:\Documents and Settings\koconnor\EclipseWorkspace\ABATE\work" >

<Resource name="jdbc/ABATE" auth="Container" scope="Shareable" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000"

username="ccn" password="ccn" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/abate?autoReconnect=true"/>

</Context>

Basically; what I need to know is how I can reference the value stored in "url" within a java class.

[1206 byte] By [JasonMcAuleya] at [2007-11-27 10:50:14]
# 1

You need to check the documentation for your server on how to create a JNDI datasource. Here is the link to the tomcat documentation:

http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html

tolmanka at 2007-7-29 11:24:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

The point is that you DON'T access the URL directly. You just look up the datasource by name: jdbc/ABATE, and ask it for a connection. It will use the url to give you a database connection.

It abstracts the connection details from your code.

evnafetsa at 2007-7-29 11:24:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...