简体   繁体   English

无法使用Oracle XE维护JDBC连接

[英]Unable to maintain JDBC connection using Oracle XE

I've set up an Oracle XE database to do some testing with an application. 我已经建立了一个Oracle XE数据库来对应用程序进行一些测试。 This application uses JDBC to work with the database. 此应用程序使用JDBC来处理数据库。 In particular, I'm using Liquibase to add/update the schema. 特别是,我正在使用Liquibase来添加/更新架构。

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

I can confirm that it gets to the database as it manages to create two tables before it errors out: 我可以确认它到达数据库,因为它在错误输出之前设法创建两个表:

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 perfectly fine with my company Oracle database, I just can't get it to work with XE. 这对我的公司Oracle数据库完全正常,我无法让它与XE一起工作。 I imagine there must be some kind of setting that I don't have configured in XE, but I'm not really sure what that would be. 我想必须有一些我在XE中没有配置的设置,但我不确定那会是什么。 It seems like the connection is being closed when it shouldn't be. 似乎连接不应该被关闭。

I tried multiple ojdbc drivers to no avail, as well. 我尝试了多个ojdbc驱动程序也无济于事。 I am able to put the connection settings in SQL Developer and easily access the database. 我能够将连接设置放在SQL Developer中并轻松访问数据库。 I also use a validation query of "SELECT 1 FROM DUAL". 我还使用了“SELECT 1 FROM DUAL”的验证查询。

If there's more information that I could provide that I haven't, let me know. 如果有更多我无法提供的信息,请告诉我。

The problem was Oracle XE does not allow partitioning. 问题是Oracle XE不允许分区。 Unfortunately, the errors and stack traces I was getting were not at all helpful, so that's why it wasn't obvious why it was failing. 不幸的是,我得到的错误和堆栈跟踪并没有任何帮助,所以这就是为什么它失败的原因并不明显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM