环境:win7,apache-tomcat-6.0.20,sql2005
问题描述:重新装完数据库,还原好备份,启动tomcat报错如下,
INFO [main] - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
WARN [main] - SQL Error: 0, SQLState: null
ERROR [main] - Cannot create PoolableConnectionFactory (Network error IOException: Connection refused: connect)
WARN [main] - Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Network error IOException: Connection refused: connect)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
……
……
问题分析:数据库的连接出现问题,1,检查配置文件,2,数据库的TCP/IP是否启动,3,数据库的端口号设置。
我的问题原因是:数据库的端口设置出现问题。
解决方案:1,修改配置文件
2,打开SQL Server Configuration Manager,SQL Server 2005网络配置- >SQL2005 的协议 - >TCP/IP 状态设置为启用;
3,打开SQL Server Configuration Manager,SQL Server 2005网络配置- >SQL2005 的协议 - >TCP/IP 右键属性,IP地址- >IPALL TCP端口:修改为1433
重启sqlserver