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 2 Next »

These instructions will help you connect TermWeb to a Microsoft SQL Server 2012 database.

1. Create and Configure the SQL Server Database

  1. Create a database for TermWeb to store data in (e.g. termwebdb). 
    • Open SQL Server Management Studio and right click on Databases and select New Database

  2. Create a database user which TermWeb will connect as (e.g. termwebuser), with permissions for the database.
    • Create a new login (right click on Security and navigate to New > Login) and name it termwebuserSelect SQL Server Authentication and enter a password for the user.
    • Create a user for the database (right click on Security under termwebdb and navigate to New > User) and name it termwebuser. Enter termwebuser as Login name, then select Membership page and select the roles db_datareader, db_datawriter and db_owner.

  3. Ensure that TCP/IP is enabled on SQL Server and listening on the correct port (which is 1433 for a default SQL Server installation).
    • Run SQL Server Configuration Manager and navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER
    • Check that the port is open in any firewall between TermWeb and SQL Server
       
  4. Ensure that SQL Server is operating in the appropriate authentication mode. 
    • By default, SQL Server operates in 'Windows Authentication mode'. However, if your user is not associated with a trusted SQL connection, i.e. 'Microsoft SQL Server, Error: 18452' is received during TermWeb startup, you will need to change the authentication mode to 'SQL Server and Windows Authentication mode'. In SQL Server Management Studio, right-click on the server and navigate to Properties > Security to change the authentication mode.

  5. Execute the termweb_sqlserver.sql file from the installation package to create the database tables.
    • If you named the database something else than termwebdb, first edit the file and enter the database name in the first statement.
    • In SQL Server Management Studio, navigate to File > Open > File and select the file.
    • Right-click and select Execute, or just press F5 to run the script.

2. Copy the SQL Server JDBC Driver to Tomcat

  1. Download the SQL Server JDBC driver (v1.3.1) from jTDS.
  2. Add the SQL Server JDBC driver jar (jtds-1.3.1.jar) to <Tomcat>/lib/ directory.

3. Configure a DataSource for TermWeb in Tomcat

  1. Edit <tomcat-install>/conf/context.xml

     

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

    <Resource name="jdbc/TermWebDS"
    auth="Container"
    type="javax.sql.DataSource"
    driverClassName="net.sourceforge.jtds.jdbc.Driver"
    url="jdbc:jtds:sqlserver://localhost/termwebdb;user=termwebuser;password=termwebpwd;useLOBs=false"
    maxActive="20"
    maxIdle="10"
    validationQuery="Select 1"/>

     

    • If you named the database something else than termwebdb, replace termwebdb in url with your database name 
    • Replace termwebuser and termwebpwd in url with your database user and password.
Notes
  • Why is the validationQuery element needed? When a database server reboots, or there is a network failure, all the connections in the connection pool are broken and this normally requires an application server reboot. 

    However, the Commons DBCP (Database Connection Pool) which is used by the Tomcat application server can validate connections before issuing them by running a simple SQL query, and if a broken connection is detected, a new one is created to replace it. To do this, you will need to set the "validationQuery" option on the database connection pool.
  • 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.
    • maxActive – The maximum number of active instances 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.
    • 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.
    • 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.


  • No labels