Hello,
I am attempting to write a simple Servlet. When I hit a submit button,
Tomcat tells me that it cannot find my Mysql driver.
The actual message is:
could not load JDBC driver ...ClassNotFoundException:com.mysql.jdbc.Driver
I have an actual driver (full path)
C:\mysql-connector-java-5.0.7\mysql-connector-java-5.0.7-bin.jar
The full path and file for my web.xml is shown below
Full Path- C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\coins\WEB-INF\web.xml is:
web.xml file-
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- Define the controller servlet -->
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.CoinSelect</servlet-class>
</servlet>
<!-- END: Define the null servlet -->
<!-- The Struts controller mapping -->
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectCoin.do</url-pattern>
</servlet-mapping>
<!-- END: The Struts controller mapping -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
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
http://www.apache.org/licenses/LICENSE-2.0 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"/>
</Context>
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!
Thank you,
Ken