How to create a JDBC Data Source with Tomcat 5 to connect to MS SQL Server

  1. Copy the driver jar file to $CATALINA_HOME/common/lib/.
  2. Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to $CATALINA_HOME/conf/server.xml.
  3. Add this before the </Host> tag closing the localhost definition.
    <Context path="/{context}" docBase="{context}" debug="5"
             reloadable="true" crossContext="true">
            <Resource name="jdbc/MS SQL" auth="Container" type="javax.sql.DataSource"/>
            <ResourceParams name="jdbc/MS SQL">
                    <!-- MS SQL dB username and password for dB connections -->
                    <!-- Class name for i-net MS SQL JDBC driver -->
                    <!-- The JDBC connection URL for connecting to your MS SQL dB. 
                         If you use more as one parameter then you need to
                         concatenate with XML coded & like &amp; -->
  4. There are some placeholders you must replace with values specific for your environment.
    • {context} - is the context, in which your application was deployed
    • {host} - is the host where the SQL Server is running and the port of the SQL Server (e.g. localhost:1433)
    • {database} - is the database name (e.g. pubs)
    • {user} - is the user for the SQL server (e.g. sa) {password} is the password for the user (e.g. password) |
  5. After changing the server.xml file, save it and restart your Apache/Tomcat.

© Copyright 1996 - 2020, i-net software; All Rights Reserved.