The following example shows how to set up a connection pool for Web Server and MySQL 4.0:
In the Web Server console, create a JDBC connection pool with the following attributes:
samplePool
com.mysql.jdbc.jdbc2.optional.MysqlDatacSource
Server name of the mySQL server.
Port number on which mySQL server is running.
User name of the database password.
The password of the user.
The name of the database.
The jar file which contain the DataSource class and the JDBC Driver class mentioned in the following steps should be added to the application class path
Configure the JDBC Resources. In the Web Server console, create a JDBC resource with the following attributes:
jdbc/samplePool
samplePool
on
Add the following lines to the sun-web.xml file of the application:
<resource-ref> <res-ref-name>jdbc/mySQL</res-ref-name> <jndi-name>jdbc/samplePool</jndi-name> </resource-ref>
Add the following lines to the web.xml file of the application:
<resource-ref> <description>mySQL Database</description> <res-ref-name>jdbc/mySQL</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Once you have completed the settings the value for this attribute is becomes java:comp/env/jdbc/mySQL.