gpt4 book ai didi

java - Spring Boot JDBC异常异常

转载 作者:行者123 更新时间:2023-11-30 02:13:44 25 4
gpt4 key购买 nike

我正在尝试学习 Spring Boot。我正在通过 Spring 网站上的教程来完成此操作。我在 eclipse 中创建了一个项目。我在 pom.xml 中添加了 JDBC 依赖项

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5.0</version>
</dependency>

我从 Oracle 下载了 ojdbc14 jar 并运行命令:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.5.0 -Dpackaging=jar -Dfile=ojdbc14.jar -DgeneratePom=true

我的 application.properties 的完成方式如下:

#Oracle connection
spring.datasource.url=jdbc:oracle:thin:@URL:1521:SID
spring.datasource.data-username=XXXX
spring.datasource.data-password=XXXX
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.show-sql=true
logging.level.org.org.springframework.retry=DEBUG
management.security.enabled=false

当我尝试启动应用程序时,我看到异常:

2018-03-14 18:02:01.013 ERROR 5844 --- [pool-1-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: invalid arguments in call
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:305) ~[spring-jdbc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378) ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:137) ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.session.jdbc.JdbcOperationsSessionRepository.cleanUpExpiredSessions(JdbcOperationsSessionRepository.java:525) ~[spring-session-jdbc-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration.lambda$configureTasks$0(JdbcHttpSessionConfiguration.java:194) ~[spring-session-jdbc-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) [spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: java.sql.SQLException: invalid arguments in call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:209) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-2.7.8.jar:na]
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:262) ~[spring-jdbc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 13 common frames omitted

最佳答案

您正在 Java 8 上运行,如果您在 12c 上运行,则需要 ojdbc7.jarojdbc8.jar 或可能需要 ojdbc6.jar 如果你还在11g。看 What are the Oracle JDBC releases versus JDK versions?了解整个兼容性列表。

不要使用ojdbc14.jar,它是很久以前针对较旧的 JVM 发布的。

此外,spring.datasource.driver-class-name=oracle.jdbc.OracleDriver 是多余的。 Spring Boot 应该根据 JDBC URL 来计算出来。

关于java - Spring Boot JDBC异常异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49289022/

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