My context.xml file has it's full path and contents listed below:
Full path: C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\context.xml
The file is: <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- The contents of this file will be loaded for each web application --> <Context>
<!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="mallory1" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
My classpath for the JDBC driver is: C:\mysql-connector-java-5.0.7\mysql-connector-java-5.0.7-bin.jar
I can get data from the database using non Servlet programs. Any insight would be greatly appreciated!
Usually the Driver would need to be included in the runtime classpath for the web application context, which involves putting it in the <context>/WEB-INF/lib directory
Since you're using a DataSource, which is managed by the container, you need to give the container access to th Driver. In your case you should place the JAR in the <TOMCAT_HOME>/common/lib directory and then restart
A quick question. Even in case there is a DataSource managed by the container wont it load the jar files in the application's WEB-INF\lib folder at the time of application startup? So my question is whether it is mandatory to have the sql driver jar in the container's lib folder in that case?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Cannot load JDBC driver for mysql in Servlet