郁闷的数据库异常
MyEclipse + Hibernate 的报如下错误: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: Cannot open connection
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.hibernate.exception.JDBCConnectionException: Cannot open connection
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
org.hibernate.loader.Loader.doQuery(Loader.java:661)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
com.accp.dingpin.server.dao.impl.hb.UserInfoDao.isExistUser(UserInfoDao.java:53)
com.accp.dingpin.server.action.LoginAction.execute(LoginAction.java:57)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败。 Connection refused: connect
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
org.hibernate.loader.Loader.doQuery(Loader.java:661)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
com.accp.dingpin.server.dao.impl.hb.UserInfoDao.isExistUser(UserInfoDao.java:53)
com.accp.dingpin.server.action.LoginAction.execute(LoginAction.java:57)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.26
我的 hibernate.cfg.xml 如下:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="myeclipse.connection.profile">SQL2005</property>
<property name="connection.password">sa</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<mapping resource="com/accp/dingpin/pojo/entity/UserT.hbm.xml" />
<mapping resource="com/accp/dingpin/pojo/entity/Products.hbm.xml" />
<mapping resource="com/accp/dingpin/pojo/entity/Categories.hbm.xml" />
</session-factory>
</hibernate-configuration>
请高手给解决一下.另外说明一下,我的电脑装了SQL2000和SQL2005
好像都不能用JDBC连接数据库