gpt4 book ai didi

java - 无法使用 Oracle XE 维护 JDBC 连接

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:23:07 25 4
gpt4 key购买 nike

我已经设置了一个 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”的验证查询。

如果有更多我可以提供但我没有提供的信息,请告诉我。

最佳答案

问题是 Oracle XE 不允许分区。不幸的是,我得到的错误和堆栈跟踪根本没有帮助,所以它失败的原因并不明显。

关于java - 无法使用 Oracle XE 维护 JDBC 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26164514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com