0

我有一台 Wildly 服务器连接到同一台机器上的 MariaDB 服务器。

出于某种原因,我不时收到此错误:

20:38:51,536 INFO  [stdout] (default task-1) 20:38:51.535 [default task-1] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 08
20:38:51,536 INFO  [stdout] (default task-1) 20:38:51.536 [default task-1] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - (conn=25) Connection reset by peer (Write failed)
20:38:51,549 INFO  [stdout] (default task-1) 20:38:51.548 [default task-1] ERROR o.s.t.i.TransactionInterceptor - Application exception overridden by rollback exception
20:38:51,550 INFO  [stdout] (default task-1) org.springframework.dao.DataAccessResourceFailureException: could not prepare statement; nested exception is org.hibernate.exception.JDBCConnectionException: could not prepare statement
20:38:51,550 INFO  [stdout] (default task-1)    at deployment.datalis_admin.war//org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:275)
20:38:51,550 INFO  [stdout] (default task-1)    at deployment.datalis_admin.war//org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:253)
20:38:51,550 INFO  [stdout] (default task-1)    at deployment.datalis_admin.war//org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)

在 MariaDB 日志中,我得到:2019-03-06 20:27:51 25 [Warning] Aborted connection 25 to db: 'production_gateway' user: 'wildfly' host: 'localhost' (Got timeout reading communication packets)

您知道可能是什么问题以及如何解决吗?

POM 文件:

https://pastebin.com/HUNy0ULy

应用程序属性:

spring.datasource.jndi-name=java:/global/production_gateway
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update

JPA 配置:

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
public class ContextDatasource {

    @Bean
    public EntityManager entityManager(EntityManagerFactory emf) {
        return emf.createEntityManager();
    }

    @Bean
    public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
        final JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(emf);
        return transactionManager;
    }

    @Bean
    public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
        return new PersistenceExceptionTranslationPostProcessor();
    }
}

JDBC驱动程序:

mariadb-java-client-2.4.0.jar

MariaDB 版本:

mysql  Ver 15.1 Distrib 10.3.13-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

你能建议吗?

4

1 回答 1

0

请向我们展示您的 pom.xml 并注意您的驱动程序版本是否也与您的数据库版本兼容。有些他们必须更新驱动程序网络,数据库开发人员进行一些更改。

于 2019-03-06T20:49:50.557 回答