Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

To be rewritten

 Rewrite like SQL Server connection page

1. Shut down Tomcat

  1. Run bin/shutdown.sh or bin/shutdown.bat to bring Tomcat down while you are making these changes.
  2. Make a backup of your server.xml and context.xml files in <tomcat-install>/conf/ so that you can easily revert if you have a problem.

2. Install the Drivers

  1. Download the MySQL Connector/J JDBC driver from http://dev.mysql.com/downloads/connector/j/
  2. After unpacking the file you have downloaded, you will find a file called something like mysql-connector-java-5.1.22-bin.jar.
  3. If you are running Tomcat 6.x or Tomcat 7.x, copy the file into <tomcat-install>/lib. On Tomcat 5.5, copy this file into the common/lib directory of your Tomcat installation.

3. Configure Tomcat

  1. For Tomcat 6.x and Tomcat 7.x, edit <tomcat-install>/conf/context.xml.
    If you are running Tomcat 5.5 you edit <tomcat-install>/conf/server.xml.

     

  2. Within the Context tags, insert the DataSource Resource tag:

     

    <Resource name="jdbc/TermWebDS"
      auth="Container"
      type="javax.sql.DataSource"
      username="termwebuser"
      password="termwebpassword"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://localhost/termweb?autoReconnect=true&amp;
    useUnicode=true&amp;characterEncoding=utf8"
      maxActive="20"
      maxIdle="10"
      validationQuery="Select 1"/>
    • Replace the username and password parameters with the correct values for your database.
    • In the url parameter, replace the word 'termweb' with the name of the database your TermWeb data will be stored in.


    The configuration properties for Tomcat's standard data source resource factory (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) are as follows:

      • driverClassName – Fully qualified Java class name of the JDBC driver to be used.
      • maxTotal – The maximum number of active connections that can be allocated from this pool at the same time.
      • maxIdle – The maximum number of connections that can sit idle in this pool at the same time.
      • minIdle – The minimum number of idle connections that will remain in this pool at the same time.
      • maxWait – The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.
      • password – Database password to be passed to our JDBC driver.
      • url – Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
      • user – Database username to be passed to our JDBC driver.
      • testWhileIdle – If the validity of the connection should be tested also when idle. Recommended to set this to true to avoid hanging connections.
      • validationQuery – SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query must be an SQL SELECT statement that returns at least one row.

4. Restart Tomcat

Run bin/startup.sh or bin/startup.bat to start Tomcat and TermWeb with the new settings.

  • No labels