我只是遵循在Netbeans页面上使用MySQL数据库创建简单Web应用程序的做法并遇到错误。
我无法使用glassfish运行我的初始步骤,因此安装tomcat并且它对于更简单的版本工作正常。添加MySQL DB后。我已经使用Netbeans glassfish功能定义了一个JDBC资源,如文档所述。但是我在我的web.xml和glassfish-resources.xml下引用了这些资源,我遇到了错误。
我认为我应该以不同于教程显示的方式将tomdb jdbc源定义为tomcat,但是我是一个新手并且没有太多的背景。
如果你能给我一些想法或新手很容易理解的参考文件,我将不胜感激。
这是日志文件。
TTP状态500 - 在第9行处理JSP页面/index.jsp时发生异常 类型异常报告 消息在第9行处理JSP页面/index.jsp时发生异常 description服务器遇到内部错误,导致无法完成此请求。
例外 org.apache.jasper.JasperException:在第9行处理JSP页面/index.jsp时发生异常
6:作者:XXX
7: - %>
8:
9:
10:SELECT subject_id,名称FROM主题
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>
答案 0 :(得分:0)
尝试
type="javax.sql.DataSource"
而不是
type="javax.sql.ConnectionPoolDataSource"
另见帖子:DataSource or ConnectionPoolDataSource for Application Server JDBC resources