Can't maintain JDBC connection using Oracle XE
I created an Oracle XE database to run some tests using the application. This application uses JDBC to work with the database. Specifically, I am using Liquibase to add / update a schema.
My JDBC connection url: jdbc: oracle: thin: @ // localhost: 1521 / xe
I can confirm that it hits the database since it manages to create two tables before they crash:
liquibase.exception.LockException: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLRecoverableException: Closed Connection
at liquibase.lockservice.LockService.releaseLock(LockService.java:152)
at liquibase.Liquibase.update(Liquibase.java:117)
at com.company.liquibase.LiquibaseAdapter.update(LiquibaseAdapter.java:53)
at com.company.startup.LiquibaseInitializingBean.afterPropertiesSet(LiquibaseInitializingBean.java:42)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFac
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactor
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.ja
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.jav
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLRecoverableException: Closed Connection
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.hasTable(JdbcDatabaseSnapshotGenerator.java:63)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.hasDatabaseChangeLogLockTable(JdbcDatabaseSnapshotGenerator.java:49)
at liquibase.database.AbstractDatabase.hasDatabaseChangeLogLockTable(AbstractDatabase.java:549)
at liquibase.lockservice.LockService.releaseLock(LockService.java:135)
... 30 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.getMetaData(PhysicalConnection.java:5216)
at org.apache.commons.dbcp.DelegatingConnection.getMetaData(DelegatingConnection.java:345)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getMetaData(PoolingDataSource.java:245)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.getMetaData(JdbcDatabaseSnapshotGenerator.java:258)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.hasTable(JdbcDatabaseSnapshotGenerator.java:54)
... 33 more
This works great with my Oracle database, I just can't seem to get it to work with XE. I'm guessing there shouldn't be any customization in XE, but I'm not entirely sure what it will be. It seems like the connection is being closed when it shouldn't.
I've tried multiple ojdbc drivers to no avail. I can set connection parameters in SQL Developer and easily access the database. I also use the "SELECT 1 FROM DUAL" validation query.
If you have any additional information I could provide, I don't know, let me know.
source to share