使用Druid连接oracle时报 java.sql.SQLException: not support oracle driver 5.1

2018-12-29 16:17:10.600 [main] ERROR c.alibaba.druid.pool.DruidDataSource 836 - {dataSource-1} init error java.sql.SQLException: ...
2018-12-29 16:17:10.600 [main] ERROR c.alibaba.druid.pool.DruidDataSource 836 - {dataSource-1} init error
java.sql.SQLException: not support oracle driver 5.1
	at com.alibaba.druid.pool.DruidDataSource.initCheck(DruidDataSource.java:1003)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:765)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1129)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1125)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:625)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:690)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:722)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:732)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:782)
	at com.gb.soa.omp.ccommon.util.MyJdbcTemplate.query(MyJdbcTemplate.java:81)
	at com.gb.pay.common.dao.PosOrderDao.getOrders(PosOrderDao.java:27)
	at com.gb.pay.common.dao.PosOrderDao$$FastClassBySpringCGLIB$$2125e6a5.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
	at com.gb.pay.common.dao.PosOrderDao$$EnhancerBySpringCGLIB$$168fbefc.getOrders(<generated>)
	at com.gb.pay.common.dao.PosOrderDaoTester.getOrders(PosOrderDaoTester.java:32)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


今天在spring boot中配置durid去连接oracle,爆了上面的异常。

在百度 谷歌搜索不出符合我的答案后 我决定调试

报错的是这行代码:

protected void initCheck() throws SQLException {
	if (JdbcUtils.ORACLE.equals(this.dbType)) {
		isOracle = true;

		if (driver.getMajorVersion() < 10) {
			throw new SQLException("not support oracle driver " + driver.getMajorVersion() + "."
								   + driver.getMinorVersion());
		}
	}
}

image.png

点进去之后:

image.png

卧槽 怎么使用mysql驱动了。

看来是配置durid的问题。

附上手工配置数据源的方法:

@Bean(name="posDataSource")
@ConfigurationProperties("oracle.pos")
public DataSource posDataSource(){
	DruidDataSource datasource = new DruidDataSource();
	datasource.setUrl(posUrl);
	datasource.setUsername(posUserName);
	datasource.setPassword(posPassword);
	datasource.setDriverClassName(oracleDrivers);
	
	datasource.setInitialSize(initialSize);
	datasource.setMinIdle(minIdle);
	datasource.setMaxActive(maxActive);
	try {
		datasource.setFilters("stat,wall,log4j");
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return datasource;
}

条评论

请先 登录 后评论
不写代码的码农
三叔

422 篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除
.localStorage.setItem(key,"has"); } })