Tomcat Netbeans 数据源无效:"java.sql.SQLException:找不到适合 jdbc 的驱动程序



我只是按照使用Netbeans页面上的MySQL数据库创建一个简单的Web应用程序的做法,遇到了一个错误。

我不能用glassfish运行我的初始步骤,所以安装tomcat,它在简单版本中工作得很好。添加完MySQL数据库后。我已经定义了一个JDBC资源,利用Netbeans的glassfish功能,如文档所述。然而,我在我的web.xml和glassfish-resources.xml下引用这些资源,我遇到了错误。

我认为我应该用一种不同于任何教程所展示的方式来定义jdbc源代码到tomcat,但是我是一个新手,没有太多的背景知识。

如果你能给我一些想法或参考文件,我将不胜感激,这是一个容易理解的新手。

日志文件。

TTP状态500 -在第9行处理JSP page/index.jsp时发生异常异常报告在第9行处理JSP page/index.jsp时发生异常服务器遇到内部错误,无法完成此请求。

异常在第9行处理JSP page/index.jsp时发生异常
6:作者:XXX
7:——%>
8:
9:
10: SELECT subject_id, name FROM subject
11:
12:

异常堆栈

:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

根源
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/IFPNEW"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:906)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:835)
org.apache.jsp.index_jsp._jspService(index_jsp.java:153)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

根源
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/IFPNEW"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:318)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:201)
org.apache.jsp.index_jsp._jspx_meth_sql_005fquery_005f0(index_jsp.java:175)
org.apache.jsp.index_jsp._jspService(index_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

context.xml

       <?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/tompool">
  <!-- maxActive: Maximum number of database connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to -1 for no limit.
         -->
  <!-- maxIdle: Maximum number of idle database connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->
  <!-- maxWait: Maximum time to wait for a database connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->
  <!-- username and password: MySQL username and password for database connections  -->
  <!-- driverClassName: Class name for the old mm.mysql JDBC driver is
         org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
         Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.
         -->
  <!-- url: The JDBC connection url for connecting to your MySQL database.
         -->
  <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/IFPNEW" password="...." type="javax.sql.ConnectionPoolDataSource" url="jdbc:mysql://localhost:3306/connpool" username="....."/>
</Context>

Try

type="javax.sql.DataSource"

代替

type="javax.sql.ConnectionPoolDataSource"

请参阅这篇文章:DataSource或ConnectionPoolDataSource的应用程序服务器JDBC资源

相关内容

  • 没有找到相关文章

最新更新