jsp mysql 连接异常

[复制链接]
查看11 | 回复4 | 2009-3-12 13:36:59 | 显示全部楼层 |阅读模式
登陆页面错误提示com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.
登录后页面提示
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /carslist.jsp:186
183: // Open Connection to the database
184: try{
185: Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
186: ResultSet rs = null;
187:
188: // Build SQL
189: String strsql = "SELECT * FROM `cars`";
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NullPointerException
org.apache.jsp.carslist_jsp._jspService(carslist_jsp.java:559)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.27
如何解决?急啊~
谢谢大大们
2楼的不行的
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.
这个产生的原因是什么
tomcat 与 mysql 需要做什么设置么?

回复

使用道具 举报

千问 | 2009-3-12 13:36:59 | 显示全部楼层
说的是数据库连接出错,下面有个空指针异常。首先是不是数据库没打开。。其次是不是数据连接写的有问题,就是数据连接的什么驱动呀还有URL USRNAME PASSWORD写的不对。检查下。。再就是程序中的问题了。。如果还没有解决建议贴全代码。。还有种可能就是你的MYsql差包。...
回复

使用道具 举报

千问 | 2009-3-12 13:36:59 | 显示全部楼层
这点代码不足以诊断出错误位置...
回复

使用道具 举报

千问 | 2009-3-12 13:36:59 | 显示全部楼层
空指针异常ResultSet rs = null; 改为ResultSet rs;...
回复

使用道具 举报

千问 | 2009-3-12 13:36:59 | 显示全部楼层
z...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行