使用dbcp在jsp中出错 [英] having error in jsp with dbcp

查看:77
本文介绍了使用dbcp在jsp中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i在通过连接池连接数据库时面临问题。

给出错误无法打开连接

i给我的网站.xml文件和context.xml文件。我正在使用tomecat

web服务器。



堆栈跟踪是: -



org.apache.tomcat.dbcp.dbcp.SQLNestedException:无法在org中加载JDBC驱动程序类''com.mysql.jdbc.Driver''

.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)

org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)< />
at com.lyricnote.support.model.WebModel.connect(WebModel.java:46)







context.xml





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


<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

- ------------




web.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>

推荐答案

无法加载JDBC驱动程序类''com.mysql.jdbc.Drive

您的应用程序无法加载mysql驱动程序。 Chcek是否正确将驱动程序jar设置到类路径
"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


这篇关于使用dbcp在jsp中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆