Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i am facing problme in connecting database throuth connection pooling.
giving error "unable to open connection"
i giving my web.xml file and context.xml file.i am using tomecat
web server.

the stack trace is:-

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.lyricnote.support.model.WebModel.connect(WebModel.java:46)



context.xml


XML
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->
	<Resource name="jdbc/LyricNote" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="prabhat" password="prabhat" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3309/support"/>



</Context>

web.xml
--------------

XML
<?xml version="1.0" encoding="ISO-8859-1"?>

<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">

   <display-name>
      Chapter 19 of JSP 2.0 - The Complete Reference
   </display-name>

   <servlet>
      <servlet-name>controller</servlet-name>
      <servlet-class>
         com.lyricnote.support.controller.ControllerServlet
      </servlet-class>
   </servlet>

   <servlet-mapping>
      <servlet-name>controller</servlet-name>
      <url-pattern>/servlet/controller/*</url-pattern>
   </servlet-mapping>

   <resource-ref>
      <description>Product support database</description>
      <res-ref-name>jdbc/LyricNote</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
   </resource-ref>

</web-app>
Posted

1 solution

"Cannot load JDBC driver class 'com.mysql.jdbc.Drive"
Your application is unable to load the mysql driver. Chcek whether you properly set the driver jar in to your classpath
 
Share this answer
 
Comments
prabhat123.ranjan 10-Apr-13 4:54am    
i have included the mysql jar file in application buil path. but still the problem is same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900