SpringBoot整合oracle报错问题
报错信息:java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z
2020-12-19 11:46:37.851 ERROR 14532 --- [nio-8080-exec-1] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Failed to execute isValid() for connection, configure connection test query (oracle.jdbc.driver.T4CConnection.isValid(I)Z).
2020-12-19 11:46:37.871 ERROR 14532 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z] with root cause
java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z
at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:445) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:412) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:370) ~[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.DataSourceUtils.fetchConnection(DataSourceUtils.java:151) ~[spring-jdbc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115) ~[spring-jdbc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78) ~[spring-jdbc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:338) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) ~[mybatis-3.4.6.jar:3.4.6]
SpringBoot整合oracle遇到的问题,由于SpringBoot是jdk1.8以上的就会导致ojdbc6和ojdbc14连接不行需要ojdbc8,由于oracle的jdbc连接是不支持maven直接下载的 所以需要下载jar包之后安装到maven本地仓库或者远程仓库:
jdbc8-12.2.0.1.jar包下载链接:官方下载链接:https://repo1.maven.org/maven2/com/oracle/database/jdbc/
或者本人CSDN资源下载地址:https://download.csdn.net/download/nan1996jiang/13713299
解决方式:
使用WIN+R打开命令提示符输入cmd;
输入该命令:mvn install:install-file -Dfile=F:\ojdbc8-12.2.0.1.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar -DgeneratePom=true
指令参数
install:可以将项目本身编译并打包到本地仓库
install-file:安装文件
-Dfile=F:\ojdbc8-12.2.0.1.jar : 指定要打的包的文件位置
-DgroupId=com.oracle : 指定当前包的groupId为com.oracle
-DartifactId=ojdbc8 : 指定当前的artifactfactId为ojdbc8
-Dversion=12.2.0.1 : 指定当前包的版本为12.2.0.1
-DgeneratePom=true:是否生成pom文件
-DgroupId=包名
-DartifactId=项目名
-Dversion=版本号
-Dpackaging=jar
-Dfile=jar文件所在路径
看到提示BUILD SUCCESS就表示成功了,然后再在SpringBoot项目当中引入pom坐标
<!--oracle连接驱动-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>