In my spring boot application I have multiple database connections SqlServer and MariaDB. In my function there are multiple DB calls over a table in MariaDB. While executing the query for the first time, data has been fetched and while executing it next time, it is giving the below error. This is coming intermittently.

2024-04-04 10:56:09 ERROR o.h.e.jdbc.spi.SqlExceptionHelper – (conn:99709) Connection reset
2024-04-04 10:56:09 WARN o.h.e.jdbc.spi.SqlExceptionHelper – SQL Error: 1220, SQLState: 08000
2024-04-04 10:56:09 ERROR o.h.e.jdbc.spi.SqlExceptionHelper – (conn:99709) Connection is close
04-Apr-2024 10:56:09.693 WARNING [http-nio-8080-exec-1] org.apache.tomcat.jdbc.pool.PooledConnection.clearWarnings Unable to clear Warnings, connection will be closed.
java.sql.SQLException: Connection.clearWarnings cannot be called on a closed connection
at org.mariadb.jdbc.internal.util.ExceptionMapper.getSqlException(ExceptionMapper.java:163)
at org.mariadb.jdbc.MariaDbConnection.clearWarnings(MariaDbConnection.java:861)
at org.apache.tomcat.jdbc.pool.PooledConnection.clearWarnings(PooledConnection.java:873)
at org.apache.tomcat.jdbc.pool.ConnectionPool.returnConnection(ConnectionPool.java:1025)
at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:103)
at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:107)
at org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.invoke(AbstractCreateStatementInterceptor.java:68)
at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:107)
at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
at com.sun.proxy.$Proxy79.close(Unknown Source)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:127)
at org.hibernate.internal.NonContextualJdbcConnectionAccess.releaseConnection(NonContextualJdbcConnectionAccess.java:46)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:196)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.close(LogicalConnectionManagedImpl.java:239)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:189)
at org.hibernate.internal.AbstractSharedSessionContract.close(AbstractSharedSessionContract.java:311)
at org.hibernate.internal.SessionImpl.close(SessionImpl.java:414)
at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
at com.sun.proxy.$Proxy97.close(Unknown Source)
at org.springframework.orm.jpa.EntityManagerFactoryUtils.closeEntityManager(EntityManagerFactoryUtils.java:421)
at org.springframework.orm.jpa.EntityManagerFactoryUtils$TransactionalEntityManagerSynchronization.releaseResource(EntityManagerFactoryUtils.java:500)
at org.springframework.orm.jpa.EntityManagerFactoryUtils$TransactionalEntityManagerSynchronization.releaseResource(EntityManagerFactoryUtils.java:440)
at org.springframework.transaction.support.ResourceHolderSynchronization.beforeCompletion(ResourceHolderSynchronization.java:77)
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCompletion(TransactionSynchronizationUtils.java:107)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCompletion(AbstractPlatformTransactionManager.java:935)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:731)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:714)
at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:566)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:298)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
at com.alt.autotagging.service.AltGroupFlatProcessingService$$EnhancerBySpringCGLIB$$66987adf.process()
at com.alt.autotagging.IMPL.AutoTaggingFlatProcessingIMPL.process(AutoTaggingFlatProcessingIMPL.java:43)
at com.alt.autotagging.IMPL.AutoTaggingFlatProcessingIMPL$$FastClassBySpringCGLIB$$e2ec9fe.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springfra

I have tried changing the tomcat connection pool settings.


spring.maria-db-autotagging.datasource.tomcat.driverClassName=org.mariadb.jdbc.Driver
spring.maria-db-autotagging.datasource.tomcat.dialect=org.hibernate.dialect.MariaDBDialect
spring.maria-db-autotagging.datasource.tomcat.initial-size=10
spring.maria-db-autotagging.datasource.tomcat.min-idle=10
spring.maria-db-autotagging.datasource.tomcat.max-idle=60
spring.maria-db-autotagging.datasource.tomcat.max-size=60
spring.maria-db-autotagging.datasource.tomcat.max-wait=20000
spring.maria-db-autotagging.datasource.tomcat.max-active=60
spring.maria-db-autotagging.datasource.tomcat.max-query-timeout=180000
spring.maria-db-autotagging.datasource.tomcat.default-auto-commit=true
spring.maria-db-autotagging.datasource.tomcat.validation-query=SELECT 1
spring.maria-db-autotagging.datasource.tomcat.validation-interval=30000
spring.maria-db-autotagging.datasource.tomcat.test-on-borrow=true
spring.maria-db-autotagging.datasource.tomcat.test-while-idle=true
spring.maria-db-autotagging.datasource.tomcat.time-between-eviction-runs-millis=60000
spring.maria-db-autotagging.datasource.tomcat.min-evictable-idle-time-millis=300000


spring.datasource.tomcat.dialect=org.hibernate.dialect.SQLServer2012Dialect

spring.datasource.tomcat.min-idle=40
spring.datasource.tomcat.max-idle=120
spring.datasource.tomcat.max-size=120

New contributor

Sampath Sammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.