jsp连接mysql问题 求大神解答。。。。
mysql-connector-java-5.0.4-bin.jar已经放到JDK1.5和Tomcat5中的bin下面环境变量的用户变量中classpath:D:\WAT...
mysql-connector-java-5.0.4-bin.jar已经放到JDK1.5和Tomcat5中的bin下面
环境变量的用户变量中classpath:D:\WATMServer\JDK1.5\bin\mysql-connector-java-5.0.4-bin.jar
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp._23_jsp._jspService(_23_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
com.mysql.jdbc.Connection.createNewIO(Connection.java:1719)
com.mysql.jdbc.Connection.<init>(Connection.java:432)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:400)
java.sql.DriverManager.getConnection(DriverManager.java:525)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp._23_jsp._jspService(_23_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 展开
环境变量的用户变量中classpath:D:\WATMServer\JDK1.5\bin\mysql-connector-java-5.0.4-bin.jar
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp._23_jsp._jspService(_23_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
com.mysql.jdbc.Connection.createNewIO(Connection.java:1719)
com.mysql.jdbc.Connection.<init>(Connection.java:432)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:400)
java.sql.DriverManager.getConnection(DriverManager.java:525)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp._23_jsp._jspService(_23_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 展开
4个回答
展开全部
1.首先你先检查数据库的链接代码是否正确
2.看看你的数据库服务有没有打开
3.看看有没有导入对应的包
4.最关键的一步,如果你使用的是jdbc-odbc桥连接的方式的话,你得先配置好数据源
配置数据源的大致步骤是:1.打开我的电脑—>2.双击控制面板—>3.双击管理工具->4.双击数据源,选择你要配置的数据库
2.看看你的数据库服务有没有打开
3.看看有没有导入对应的包
4.最关键的一步,如果你使用的是jdbc-odbc桥连接的方式的话,你得先配置好数据源
配置数据源的大致步骤是:1.打开我的电脑—>2.双击控制面板—>3.双击管理工具->4.双击数据源,选择你要配置的数据库
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在配置环境变量的时候要先配置一个名为Catalina_base值为tomcat的安装目录,还有一个名为Catalina_home值为tomcat的安装目录,再在classpath后加(;%Catalina_home\lib\mysql-connector-java-5.0.4-bin.jar),看你上面的错误好像是Connection类里面写错什么了,你在上面提示的类里找一下错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jsp连接SQL要一个java类的,估计是那个类写错了。
java.sql.SQLException: Unable to connect to any hosts due to exception
不能够连接到任何主机
java.sql.SQLException: Unable to connect to any hosts due to exception
不能够连接到任何主机
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
mysql-connector-java-5.0.4-bin.jar
亲,你要不换3.0.X的jar包吧
亲,你要不换3.0.X的jar包吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询