Mysql 无法针对JDBC连接提交

Mysql 无法针对JDBC连接提交,mysql,spring-boot,spring-jdbc,Mysql,Spring Boot,Spring Jdbc,我正在使用springboot连接到mysql数据库。请在下面找到我的配置 spring.datasource.url=jdbc:<connection-url> spring.datasource.username=<username> spring.datasource.password=<password> spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.jpa.sh

我正在使用springboot连接到mysql数据库。请在下面找到我的配置

spring.datasource.url=jdbc:<connection-url>
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true

spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.min-idle=15
以下是我的例外

 org.springframework.orm.jpa.JpaSystemException: Unable to commit against JDBC Connection; nested exception is org.hibernate.TransactionException: Unable to commit against JDBC Connection
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:353) ~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255) ~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:538) ~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) [spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) [spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:665) [spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:370) [spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) [spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) [spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) [spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at com.server.controller.SubscribeController$$EnhancerBySpringCGLIB$$14f090fd.subscribeTopic(<generated>) [classes!/:0.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251]
org.springframework.orm.jpa.JpaSystemException:无法针对JDBC连接提交;嵌套异常为org.hibernate.TransactionException:无法针对JDBC连接提交
在org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:353)~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateException如果可能(HibernateJpaDialect.java:255)~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:538)~[spring-orm-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)[spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)[spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
位于org.springframework.transaction.interceptor.TransactionSpectSupport.CompleteTransactionSpectActionAfterThrowing(TransactionSpectSupport.java:665)[spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.transaction.interceptor.TransactionSpectSupport.invokeWithinTransaction(TransactionSpectSupport.java:370)[spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)[spring-tx-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:186)[spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.procedue(CglibAopProxy.java:749)[spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)[spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
在com.server.controller.SubscribeController$$EnhancerBySpringCGLIB$$14f090fd.subscribeTopic()[classes!/:0.0.1-SNAPSHOT]
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)~[na:1.8.0\u 251]
得到答案了吗

更新了resource.properties

spring.datasource.url=jdbc:<connection-url>
spring.datasource.username=<username>
spring.datasource.password=<password>
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true

spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5
spring.datasource.url=jdbc:
spring.datasource.username=
spring.datasource.password=
#spring.datasource.driver类名=com.mysql.cj.jdbc.driver
spring.jpa.show sql=true
spring.jpa.hibernate.ddl auto=update
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5
得到答案了吗

更新了resource.properties

spring.datasource.url=jdbc:<connection-url>
spring.datasource.username=<username>
spring.datasource.password=<password>
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true

spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5
spring.datasource.url=jdbc:
spring.datasource.username=
spring.datasource.password=
#spring.datasource.driver类名=com.mysql.cj.jdbc.driver
spring.jpa.show sql=true
spring.jpa.hibernate.ddl auto=update
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5

我在Spring/Postgres堆栈上遇到了相同的异常。基本上,数据库不能及时返回/提交与查询匹配的所有行

可以通过在特定查询中使用的列上创建索引来修复此问题。这加快了查询速度

CREATE INDEX index_redflag_person
ON redflag_person (firstname, alias,lastname,address,birthplace);

我在Spring/Postgres堆栈上遇到了相同的异常。基本上,数据库不能及时返回/提交与查询匹配的所有行

可以通过在特定查询中使用的列上创建索引来修复此问题。这加快了查询速度

CREATE INDEX index_redflag_person
ON redflag_person (firstname, alias,lastname,address,birthplace);

为什么需要添加
@Transactional
?是否@Transactional不确保自动提交和自动关闭connection@user7294900我已经删除了注释,仍然是相同的问题为什么需要添加
@Transactional
,不确保自动提交和自动关闭connection@user7294900我已经删除了注释,仍然是同一个问题