##### To Configure a Connection Pool — Example

The following example shows how to set up a connection pool for Web Server and MySQL 4.0:

1. In the Web Server console, create a JDBC connection pool with the following attributes:
   poolName

     `samplePool`

   DataSource Classname

     `com.mysql.jdbc.jdbc2.optional.MysqlDatacSource`

   serverName

     Server name of the mySQL server.

   port

     Port number on which mySQL server is running.

   user

     User name of the database password.

   password

     The password of the user.

   databaseName

     The name of the database.

   Note – 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

2. Configure the JDBC Resources. In the Web Server console, create a JDBC resource with the following attributes:
   JNDI name

     jdbc/samplePool

   Pool name

     samplePool

   Data Resource Enabled

     on

3. 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>

4. 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>

5. Once you have completed the settings the value for this attribute is becomes java:comp/env/jdbc/mySQL.