无法使用Oracle XE维护JDBC连接

时间:2014-10-02 15:45:39

标签: java oracle jdbc liquibase oracle-xe

我已经建立了一个Oracle XE数据库来对应用程序进行一些测试。此应用程序使用JDBC来处理数据库。特别是,我正在使用Liquibase来添加/更新架构。

我的JDBC连接url是:jdbc:oracle:thin:@ // localhost:1521 / xe

我可以确认它到达数据库,因为它设法在错误输出之前创建两个表:

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

这对我的公司Oracle数据库完全正常,我无法让它与XE一起工作。我想必须有一些我在XE中没有配置的设置,但我不确定那会是什么。似乎连接不应该被关闭。

我尝试了多个ojdbc驱动程序也无济于事。我能够将连接设置放在SQL Developer中并轻松访问数据库。我还使用了“SELECT 1 FROM DUAL”的验证查询。

如果有更多我无法提供的信息,请告诉我。

1 个答案:

答案 0 :(得分:2)

问题是Oracle XE不允许分区。不幸的是,我得到的错误和堆栈痕迹根本没有用,所以这就是为什么它失败的原因并不明显。