Stuckup with - HikariCP : JZ0C0: 连接已经关闭(Sybase DB with SpringBoot v2.1.7)
Stuckup with - HikariCP : JZ0C0: Connection is already closed (Sybase DB with SpringBoot v2.1.7)
我收到 Connection is already closed issue,用于 CommandLineRunner -Spring 启动应用程序。
这是我正在使用的技术堆栈
- SpringBoot v2.1.7
- Sybase 数据库 v16.x 与 jconn4
HikarCP - 配置信息:
DEBUG] 2020-05-22 10:51:58.449 [main] o.s.j.d.DataSourceUtils - Fetching JDBC Connection from DataSource
[DEBUG] 2020-05-22 10:51:58.450 [main] c.z.h.HikariConfig - GBSHikariCP - configuration:
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - allowPoolSuspension.............false
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - autoCommit......................true
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - catalog.........................none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionInitSql...............none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionTestQuery............."SELECT 1"
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionTimeout...............30000
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSource......................none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSourceClassName.............none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSourceJNDI..................none
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - dataSourceProperties............{password=<masked>}
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - driverClassName................."com.sybase.jdbc4.jdbc.SybDriver"
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - healthCheckProperties...........{}
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - healthCheckRegistry.............none
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - idleTimeout.....................30000
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - initializationFailTimeout.......1
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - isolateInternalQueries..........false
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - jdbcUrl.........................jdbc:sybase:Tds:xxxxx.xxx.xx.xx:11111/SOMEDB
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - leakDetectionThreshold..........2500
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - maxLifetime.....................90000
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - maximumPoolSize.................20
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - metricRegistry..................none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - metricsTrackerFactory...........none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - minimumIdle.....................5
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - password........................<masked>
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - poolName........................"HikariCP"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - readOnly........................false
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - registerMbeans..................false
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - scheduledExecutor...............none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - schema.........................."dbo"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - threadFactory...................internal
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - transactionIsolation............default
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - username........................"usr111"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - validationTimeout...............10000
这是我在 STS 控制台上看到的堆栈跟踪
2020-05-22 10:51:58.857 [main] c.z.h.p.PoolBase - HikariCP - Closing connection com.sybase.jdbc4.jdbc.SybConnection@4a183d02: (Failed to create/setup connection)
[DEBUG] 2020-05-22 10:51:58.859 [main] c.z.h.p.PoolBase - GBSHikariCP - Closing connection com.sybase.jdbc4.jdbc.SybConnection@4a183d02 failed
java.sql.SQLException: JZ0C0: Connection is already closed.
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.checkConnection(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.close(Unknown Source)
at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:135)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:380)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356)
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73)
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142)
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:113)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2.CGLIB$jpaVendorAdapter(<generated>)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2$$FastClassBySpringCGLIB$e5bd134.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2.jpaVendorAdapter(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
at com.xxx.xx.xxx.jrt.JOBRunTP.main(JOBRunTP.java:44)
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: JZ0C0: Connection is already closed.
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
... 61 common frames omitted
Caused by: java.sql.SQLException: JZ0C0: Connection is already closed.
at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.handleSQLE(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.isReadOnly(Unknown Source)
at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:413)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:374)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
我还观察到,相同的连接配置与不同的 Sybase 用户 ID 完美配合。该问题是否特定于数据库用户 ID?任何人都可以帮助我我哪里做错了。
最后这个问题已经通过添加自定义数据源属性解决了,如下面在 spring 启动 application.yml 文件中提到的。希望这对其他人有帮助。
这些属性已在 sybase 数据库中进行了验证。 (其特定于应用程序的验证)。
spring:
datasource:
hikari:
data-source-properties:
SELECT_OPENS_CURSOR : true
applicationName: GBS«¼Æ¢ó½Ç²îª°»L
我收到 Connection is already closed issue,用于 CommandLineRunner -Spring 启动应用程序。 这是我正在使用的技术堆栈
- SpringBoot v2.1.7
- Sybase 数据库 v16.x 与 jconn4
HikarCP - 配置信息:
DEBUG] 2020-05-22 10:51:58.449 [main] o.s.j.d.DataSourceUtils - Fetching JDBC Connection from DataSource
[DEBUG] 2020-05-22 10:51:58.450 [main] c.z.h.HikariConfig - GBSHikariCP - configuration:
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - allowPoolSuspension.............false
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - autoCommit......................true
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - catalog.........................none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionInitSql...............none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionTestQuery............."SELECT 1"
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - connectionTimeout...............30000
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSource......................none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSourceClassName.............none
[DEBUG] 2020-05-22 10:51:58.451 [main] c.z.h.HikariConfig - dataSourceJNDI..................none
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - dataSourceProperties............{password=<masked>}
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - driverClassName................."com.sybase.jdbc4.jdbc.SybDriver"
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - healthCheckProperties...........{}
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - healthCheckRegistry.............none
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - idleTimeout.....................30000
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - initializationFailTimeout.......1
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - isolateInternalQueries..........false
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - jdbcUrl.........................jdbc:sybase:Tds:xxxxx.xxx.xx.xx:11111/SOMEDB
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - leakDetectionThreshold..........2500
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - maxLifetime.....................90000
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - maximumPoolSize.................20
[DEBUG] 2020-05-22 10:51:58.452 [main] c.z.h.HikariConfig - metricRegistry..................none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - metricsTrackerFactory...........none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - minimumIdle.....................5
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - password........................<masked>
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - poolName........................"HikariCP"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - readOnly........................false
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - registerMbeans..................false
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - scheduledExecutor...............none
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - schema.........................."dbo"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - threadFactory...................internal
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - transactionIsolation............default
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - username........................"usr111"
[DEBUG] 2020-05-22 10:51:58.453 [main] c.z.h.HikariConfig - validationTimeout...............10000
这是我在 STS 控制台上看到的堆栈跟踪
2020-05-22 10:51:58.857 [main] c.z.h.p.PoolBase - HikariCP - Closing connection com.sybase.jdbc4.jdbc.SybConnection@4a183d02: (Failed to create/setup connection)
[DEBUG] 2020-05-22 10:51:58.859 [main] c.z.h.p.PoolBase - GBSHikariCP - Closing connection com.sybase.jdbc4.jdbc.SybConnection@4a183d02 failed
java.sql.SQLException: JZ0C0: Connection is already closed.
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.checkConnection(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.close(Unknown Source)
at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:135)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:380)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356)
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73)
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142)
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:113)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2.CGLIB$jpaVendorAdapter(<generated>)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2$$FastClassBySpringCGLIB$e5bd134.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$d0516b2.jpaVendorAdapter(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=11=](AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
at com.xxx.xx.xxx.jrt.JOBRunTP.main(JOBRunTP.java:44)
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: JZ0C0: Connection is already closed.
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
... 61 common frames omitted
Caused by: java.sql.SQLException: JZ0C0: Connection is already closed.
at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.handleSQLE(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.isReadOnly(Unknown Source)
at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:413)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:374)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
我还观察到,相同的连接配置与不同的 Sybase 用户 ID 完美配合。该问题是否特定于数据库用户 ID?任何人都可以帮助我我哪里做错了。
最后这个问题已经通过添加自定义数据源属性解决了,如下面在 spring 启动 application.yml 文件中提到的。希望这对其他人有帮助。 这些属性已在 sybase 数据库中进行了验证。 (其特定于应用程序的验证)。
spring:
datasource:
hikari:
data-source-properties:
SELECT_OPENS_CURSOR : true
applicationName: GBS«¼Æ¢ó½Ç²îª°»L