我的应用程序在 MySql 5.6 中运行,我正在使用 Hibernate、Spring 和 Tomcat7。在我的应用程序在我的个人计算机(Windows 7 32 位)上完美运行之前,但我将其移至服务器(Windows Server 2008 64 位)。
当我启动服务器时,一切正常,直到它尝试加载这个库"org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider".
实际上具体的线路是:
INFORMACIÓN: Initializing connection provider:
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
在此服务器等待大约 45 秒后尝试加载它,并且出现以下错误:
INFORMACIÓN: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
nov 06, 2013 9:08:53 AM org.slf4j.impl.JCLLoggerAdapter warn
ADVERTENCIA: SQL Error: 0, SQLState: 08S01
nov 06, 2013 9:08:53 AM org.slf4j.impl.JCLLoggerAdapter error
GRAVE: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
nov 06, 2013 9:08:53 AM org.slf4j.impl.JCLLoggerAdapter warn
ADVERTENCIA: Could not obtain connection to query metadata
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
这是我与数据库连接并映射资源的“applicationContext.xml”。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- Configuración del datasource para hibernate -->
<bean
id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/secretaria</value>
</property>
<property name="username">
<value>secretaria</value>
</property>
<property name="password">
<value>1234</value>
</property>
</bean>
<!-- Factoria de sesiones de Hibernate -->
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>secretaria/beans/prueba.hbm.xml</value>
<value>secretaria/beans/lotes.hbm.xml</value>
<value>secretaria/beans/expediente.hbm.xml</value>
<value>secretaria/beans/prorroga.hbm.xml</value>
<value>secretaria/beans/plurianual.hbm.xml</value>
<value>secretaria/beans/modificado.hbm.xml</value>
<value>secretaria/beans/empresa.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQL5InnoDBDialect
</prop>
<prop key="hibernate.hbm2ddl.auto">
update
</prop>
<prop key="hibernate.show_sql">
true
</prop>
<prop key="hibernate.format_sql">
true
</prop>
</props>
</property>
</bean>
<!-- Interceptor para transacciones de Hibernate -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<import resource="classpath:actions.spring.xml"/>
<import resource="classpath:dao.spring.xml"/>
<import resource="classpath:services.spring.xml"/>
</beans>
我尝试更新 springframeworks 库、tomcat、重置服务器并哭泣,但一切正常。我能做些什么???感谢您的回答!!!