愁死我了。弄了很长时间都报下面的错。用户名密码正确,装MYSQL时勾选了允许远程调用,不知道还有哪儿不对的。急啊。帮帮忙!
- [ INFO] 2011-07-22 14:42:56,937 [] [] Building new Hibernate SessionFactory
- [ INFO] 2011-07-22 14:42:57,343 [] [] Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
- [ WARN] 2011-07-22 14:42:58,859 [] [] SQL Error: 0, SQLState: null
- [ERROR] 2011-07-22 14:42:58,859 [] [] Cannot create PoolableConnectionFactory (到主机 的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect)
- [ WARN] 2011-07-22 14:42:58,921 [] [] Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (到主机 的 TCP/IP 连接失败。 java.net.ConnectException: 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:82)
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)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
... 49 more
- [ INFO] 2011-07-22 14:42:59,453 [] [] Using dialect: org.hibernate.dialect.SQLServerDialect
- [ INFO] 2011-07-22 14:42:59,484 [] [] Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
- [ INFO] 2011-07-22 14:42:59,500 [] [] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
- [ INFO] 2011-07-22 14:42:59,500 [] [] Automatic flush during beforeCompletion(): disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Automatic session close at end of transaction: disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Scrollable result sets: disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] JDBC3 getGeneratedKeys(): disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Connection release mode: auto
- [ INFO] 2011-07-22 14:42:59,500 [] [] Default batch fetch size: 1
- [ INFO] 2011-07-22 14:42:59,500 [] [] Generate SQL with comments: disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Order SQL updates by primary key: disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Order SQL inserts for batching: disabled
- [ INFO] 2011-07-22 14:42:59,500 [] [] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
- [ INFO] 2011-07-22 14:42:59,531 [] [] Using ASTQueryTranslatorFactory
- [ INFO] 2011-07-22 14:42:59,531 [] [] Query language substitutions: {}
- [ INFO] 2011-07-22 14:42:59,531 [] [] JPA-QL strict compliance: disabled
- [ INFO] 2011-07-22 14:42:59,531 [] [] Second-level cache: enabled
- [ INFO] 2011-07-22 14:42:59,531 [] [] Query cache: disabled
- [ INFO] 2011-07-22 14:42:59,531 [] [] Cache provider: org.hibernate.cache.NoCacheProvider
- [ INFO] 2011-07-22 14:42:59,531 [] [] Optimize cache for minimal puts: disabled
- [ INFO] 2011-07-22 14:42:59,531 [] [] Structured second-level cache entries: disabled
- [ INFO] 2011-07-22 14:42:59,562 [] [] Echoing all SQL to stdout
- [ INFO] 2011-07-22 14:42:59,562 [] [] Statistics: disabled
- [ INFO] 2011-07-22 14:42:59,562 [] [] Deleted entity synthetic identifier rollback: disabled
- [ INFO] 2011-07-22 14:42:59,562 [] [] Default entity-mode: pojo
- [ INFO] 2011-07-22 14:42:59,562 [] [] Named query checking : enabled
--转自