snipt

Ctrl+h for KB shortcuts

Text only

Configure Tomcat for Database Access

The database installation instructions and sample JSP program included with the Tomcat distribution docs will work on OS X 10.5 and J2SE 1.5. I used the following combination of packages:

MySQL 5.0.51 Database
MySQL Connector/J 5.1.5-bin
Jakarta Standard Taglibs 1.1.2
Be sure to look at the Application Developer's Guide documentation for an example on how to build your first application. It includes a sample build.xml file and source directory structure that you can use as a template for your other projects.

MySQL Database

There are a number of sites around the internet that cover the installation of MySQL on OS X Leopard. Here are a few:

Compiling and Installing MySQL on OS X Leopard

Compiling MySQL on OS X

Installing MySQL on OS X

MySQL Database Server

Apache Xalan-J 2.7.1

The Java 5 SDK on OS X ships with an old version of Xalan, it's a good idea to update to the latest version. The Apache Xalan XML transformation processor can be downloaded from the Apache Xalan site. I recommend downloading the source code archive xalan-j_2_7_1-src-2jars.tar.gz and compiling it.
You will need to convert the CRLF line endings in build.sh to LF line endings. 
Execute the command: perl -pi -e 's,\r\n,\n,' build.sh
To compile the complete package execute a sh build.sh all command in terminal. To compile the documentation execute a sh build.sh docs command.

Copy the files serializer.jar and xalan.jar from the build folder to /Library/Java/Extensions folder.

Apache Xerces-J 2.9.0

Upadating the XML parser is also a good idea as you should keep Xerces and Xalan in sync. The Xerces XML parser can be downloaded from the Apache Xerces site. I recommend downloading the source code archive Xerces-J-src.2.9.0.tar.gz and compiling it. To build Xerces you will also need the tools archive Xerces-J-tools.2.9.0.tar.gz. The tools folder must be put under the main Xerces source folder. To compile the complete package with documentation execute a sh build.sh all command in terminal.

Copy the files resolver.jar, xercesImpl.jar, and xml-apis.jar.jar from the build folder to /Library/Java/Extensions folder.

MySQL Connector/J

The MySQL Connector can be downloaded from the MySQL AB Connector/J 5.1 site. See Connecter/J versions.

The Connector/J mysql-connector-java-5.1.5-bin.jar file should be copied to $CATALINA_HOME/lib or /Library/Java/Extensions folder.

Jakarta Standard Taglibs 1.1.2

The Standard Taglibs files jstl.jar and standard.jar are included with the Tomcat sample code at $CATALINA_HOME/webapps/examples/WEB-INF/lib, but it is useful to know where they came from. You can download the standard tag library from the Apache Taglibs project.

Sample Database JSP Example Program Configuration File

The database configuration XML should not be placed in server.xml, but should be placed in it's own separate context.xml configuration file. This file can be placed in several locations depending on whether you want the context element to be used by all applications or just one. Place the context.xml file either in $CATALINA_HOME/conf directory or the sample application's DBTest/web/META-INF directory.
https://snipt.net/embed/1fb25be68dcf28c557fbcc4e6f3fcba8/
/raw/1fb25be68dcf28c557fbcc4e6f3fcba8/
1fb25be68dcf28c557fbcc4e6f3fcba8
text
Text only
49
2019-06-19T02:40:10
True
False
False
/api/public/snipt/33632/
configure-tomcat-for-database-access
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a> <a href="#L-14">14</a> <a href="#L-15">15</a> <a href="#L-16">16</a> <a href="#L-17">17</a> <a href="#L-18">18</a> <a href="#L-19">19</a> <a href="#L-20">20</a> <a href="#L-21">21</a> <a href="#L-22">22</a> <a href="#L-23">23</a> <a href="#L-24">24</a> <a href="#L-25">25</a> <a href="#L-26">26</a> <a href="#L-27">27</a> <a href="#L-28">28</a> <a href="#L-29">29</a> <a href="#L-30">30</a> <a href="#L-31">31</a> <a href="#L-32">32</a> <a href="#L-33">33</a> <a href="#L-34">34</a> <a href="#L-35">35</a> <a href="#L-36">36</a> <a href="#L-37">37</a> <a href="#L-38">38</a> <a href="#L-39">39</a> <a href="#L-40">40</a> <a href="#L-41">41</a> <a href="#L-42">42</a> <a href="#L-43">43</a> <a href="#L-44">44</a> <a href="#L-45">45</a> <a href="#L-46">46</a> <a href="#L-47">47</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>The database installation instructions and sample JSP program included with the Tomcat distribution docs will work on OS X 10.5 and J2SE 1.5. I used the following combination of packages: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>MySQL 5.0.51 Database </span><span id="L-4"><a name="L-4"></a>MySQL Connector/J 5.1.5-bin </span><span id="L-5"><a name="L-5"></a>Jakarta Standard Taglibs 1.1.2 </span><span id="L-6"><a name="L-6"></a>Be sure to look at the Application Developer&#39;s Guide documentation for an example on how to build your first application. It includes a sample build.xml file and source directory structure that you can use as a template for your other projects. </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a>MySQL Database </span><span id="L-9"><a name="L-9"></a> </span><span id="L-10"><a name="L-10"></a>There are a number of sites around the internet that cover the installation of MySQL on OS X Leopard. Here are a few: </span><span id="L-11"><a name="L-11"></a> </span><span id="L-12"><a name="L-12"></a>Compiling and Installing MySQL on OS X Leopard </span><span id="L-13"><a name="L-13"></a> </span><span id="L-14"><a name="L-14"></a>Compiling MySQL on OS X </span><span id="L-15"><a name="L-15"></a> </span><span id="L-16"><a name="L-16"></a>Installing MySQL on OS X </span><span id="L-17"><a name="L-17"></a> </span><span id="L-18"><a name="L-18"></a>MySQL Database Server </span><span id="L-19"><a name="L-19"></a> </span><span id="L-20"><a name="L-20"></a>Apache Xalan-J 2.7.1 </span><span id="L-21"><a name="L-21"></a> </span><span id="L-22"><a name="L-22"></a>The Java 5 SDK on OS X ships with an old version of Xalan, it&#39;s a good idea to update to the latest version. The Apache Xalan XML transformation processor can be downloaded from the Apache Xalan site. I recommend downloading the source code archive xalan-j_2_7_1-src-2jars.tar.gz and compiling it. </span><span id="L-23"><a name="L-23"></a>You will need to convert the CRLF line endings in build.sh to LF line endings. </span><span id="L-24"><a name="L-24"></a>Execute the command: perl -pi -e &#39;s,\r\n,\n,&#39; build.sh </span><span id="L-25"><a name="L-25"></a>To compile the complete package execute a sh build.sh all command in terminal. To compile the documentation execute a sh build.sh docs command. </span><span id="L-26"><a name="L-26"></a> </span><span id="L-27"><a name="L-27"></a>Copy the files serializer.jar and xalan.jar from the build folder to /Library/Java/Extensions folder. </span><span id="L-28"><a name="L-28"></a> </span><span id="L-29"><a name="L-29"></a>Apache Xerces-J 2.9.0 </span><span id="L-30"><a name="L-30"></a> </span><span id="L-31"><a name="L-31"></a>Upadating the XML parser is also a good idea as you should keep Xerces and Xalan in sync. The Xerces XML parser can be downloaded from the Apache Xerces site. I recommend downloading the source code archive Xerces-J-src.2.9.0.tar.gz and compiling it. To build Xerces you will also need the tools archive Xerces-J-tools.2.9.0.tar.gz. The tools folder must be put under the main Xerces source folder. To compile the complete package with documentation execute a sh build.sh all command in terminal. </span><span id="L-32"><a name="L-32"></a> </span><span id="L-33"><a name="L-33"></a>Copy the files resolver.jar, xercesImpl.jar, and xml-apis.jar.jar from the build folder to /Library/Java/Extensions folder. </span><span id="L-34"><a name="L-34"></a> </span><span id="L-35"><a name="L-35"></a>MySQL Connector/J </span><span id="L-36"><a name="L-36"></a> </span><span id="L-37"><a name="L-37"></a>The MySQL Connector can be downloaded from the MySQL AB Connector/J 5.1 site. See Connecter/J versions. </span><span id="L-38"><a name="L-38"></a> </span><span id="L-39"><a name="L-39"></a>The Connector/J mysql-connector-java-5.1.5-bin.jar file should be copied to $CATALINA_HOME/lib or /Library/Java/Extensions folder. </span><span id="L-40"><a name="L-40"></a> </span><span id="L-41"><a name="L-41"></a>Jakarta Standard Taglibs 1.1.2 </span><span id="L-42"><a name="L-42"></a> </span><span id="L-43"><a name="L-43"></a>The Standard Taglibs files jstl.jar and standard.jar are included with the Tomcat sample code at $CATALINA_HOME/webapps/examples/WEB-INF/lib, but it is useful to know where they came from. You can download the standard tag library from the Apache Taglibs project. </span><span id="L-44"><a name="L-44"></a> </span><span id="L-45"><a name="L-45"></a>Sample Database JSP Example Program Configuration File </span><span id="L-46"><a name="L-46"></a> </span><span id="L-47"><a name="L-47"></a>The database configuration XML should not be placed in server.xml, but should be placed in it&#39;s own separate context.xml configuration file. This file can be placed in several locations depending on whether you want the context element to be used by all applications or just one. Place the context.xml file either in $CATALINA_HOME/conf directory or the sample application&#39;s DBTest/web/META-INF directory. </span></pre></div> </td></tr></table>
database, setup, tomcat