NutzCN Logo
问答 Nutz无法连接oracle的问题
发布于 3269天前 作者 qq_c239cfa8 5859 次浏览 复制 上一个帖子 下一个帖子
标签: dao oracle

参照nutzbook项目var ioc = {
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : "jdbc:oracle:thin:@localhost:1521:epsit",
username : "ep2das",
password : "ep2das",
testWhileIdle : true,
maxActive : 100
}
}
报错:
一月 10, 2016 11:57:05 上午 com.alibaba.druid.pool.DruidDataSource error
严重: create connection error, url: jdbc:oracle:thin:@localhost:epsit
java.sql.SQLException: validateConnection false
at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1227)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1450)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1881)
一月 10, 2016 11:57:05 上午 com.alibaba.druid.pool.DruidDataSource error
严重: create connection error, url: jdbc:oracle:thin:@localhost:epsit
java.sql.SQLException: validateConnection false
at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1227)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1450)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1881)
一月 10, 2016 11:57:06 上午 com.alibaba.druid.pool.DruidDataSource error
严重: create connection error, url: jdbc:oracle:thin:@localhost:1521:epsit
java.sql.SQLException: validateConnection false
at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1227)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1450)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1881)
一月 10, 2016 11:57:06 上午 com.alibaba.druid.pool.DruidDataSource error
严重: create connection error, url: jdbc:oracle:thin:@localhost:1521:epsit

8 回复

首先,把testWhileIdle 注释试试,如果ok,继续往下看, 否则检查数据库是不是真的连不上
然后, 加上 下面的配置试试

validationQuery : "select 1 from dual",

@谢谢您,一语中的,现在报的错误好像是驱动不匹配的问题,我用的包

2016-1-10 13:26:3.35 DEBUG [main] Database don't support auto-increment. If insert fail, pls add trigger in database or using @Prev in Pojo
2016-1-10 13:26:3.70 DEBUG [main] SELECT COUNT(*) FROM t_user
2016-1-10 13:26:3.92 ERROR [main] Error happend during start serivce!
java.lang.RuntimeException: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.setSavepoint()Ljava/sql/Savepoint; 8582b391_png

<em>@2_Q<code>_2RJ</code>_2_3KH</em>_L_N9_png上面的那个图错了,是这个;

用ojdbc6, 别用什么class14之类的老掉牙的驱动

@还是谢谢您,但是我换了这个包之后还是报这个错
2016-1-10 13:34:48.951 DEBUG [main] Database info --> ORACLE:[Oracle - Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options]
2016-1-10 13:34:48.963 DEBUG [main] Found 3 resource by src( net/wendal/nutzbook/ ) , regex( ^.+[.]class$ )
2016-1-10 13:34:49.80 DEBUG [main] Database don't support auto-increment. If insert fail, pls add trigger in database or using @Prev in Pojo
2016-1-10 13:34:49.120 DEBUG [main] SELECT COUNT(*) FROM t_user
2016-1-10 13:34:49.143 ERROR [main] Error happend during start serivce!
java.lang.RuntimeException: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.setSavepoint()Ljava/sql/Savepoint;
at org.nutz.lang.Lang.wrapThrow(Lang.java:148)
at org.nutz.trans.Trans.exec(Trans.java:179)
at org.nutz.trans.Trans.exec(Trans.java:132)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:239)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:144)
at net.wendal.nutzbook.MainSetup.init(MainSetup.java:26)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:270)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:119)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter.init(NutFilter.java:78)

100%是还有老驱动没删掉

@嗯,是的,多谢您

添加回复
请先登陆
回到顶部