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

大家好,我参考Nutz-book项目之后想要把数据库从**mysql**改为**oracle**,但是项目启动不起来,提示*ERROR - dataSource init error*
我的**dao.js里面的部分内容**为:

dataSource : {
            type : "com.alibaba.druid.pool.DruidDataSource",
            events : {
                create : "init",
                depose : 'close'
            },
            fields : {
                url : {java:"$conf.get('db.url')"},
                username : {java:"$conf.get('db.username')"},
                password : {java:"$conf.get('db.password')"},
                testWhileIdle : true,
                validationQuery : {java:"$conf.get('db.validationQuery')"},
                maxActive : {java:"$conf.get('db.maxActive')"},
                filters : "mergeStat",
                connectionProperties : "druid.stat.slowSqlMillis=2000"
            }
        }

db的配置文件:

db.url=jdbc:oracle:thin:@192.168.140.149:1521:MyDatabase
db.username=Account
db.password=123456
db.validationQuery=select 1
db.maxActive=100

一部分错误提示:

2015-11-02 16:38:31,350 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:660) ERROR - dataSource init error
java.sql.SQLException: oracle.jdbc.driver.OracleDriver
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:528)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:597)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
	at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:74)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:73)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:140)
	at iie.wxcj.MainSetup.init(MainSetup.java:35)
	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.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399)
	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:633)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1672)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:191)
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:526)
	... 35 more
2015-11-02 16:38:31,354 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:669) INFO  - {dataSource-1} inited
2015-11-02 16:38:31,354 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:79) DEBUG - Remove object 'dataSource' from [app] 
2015-11-02 16:38:31,355 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:79) DEBUG - Remove object 'dao' from [app] 
2015-11-02 16:38:31,355 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:123) ERROR - Error happend during start serivce!
org.nutz.ioc.IocException: java.sql.SQLException: oracle.jdbc.driver.OracleDriver FAIL to create Ioc Bean name=[dataSource] 
beacase [java.sql.SQLException: oracle.jdbc.driver.OracleDriver] FAIL to create Ioc Bean name=[dao] 
beacase [java.sql.SQLException: oracle.jdbc.driver.OracleDriver FAIL to create Ioc Bean name=[dataSource] 
beacase [java.sql.SQLException: oracle.jdbc.driver.OracleDriver]]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:140)
	at iie.wxcj.MainSetup.init(MainSetup.java:35)
	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.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399)
	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:633)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1672)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.ioc.IocException: java.sql.SQLException: oracle.jdbc.driver.OracleDriver FAIL to create Ioc Bean name=[dataSource] 
beacase [java.sql.SQLException: oracle.jdbc.driver.OracleDriver]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:73)
	... 24 more

谢谢解答!!!

4 回复

上面不清楚,看这一层

我参考Nutz-book项目之后想要把数据库从 mysql 改为 oracle ,但是项目启动不起来,提示
ERROR - dataSource init error
dao.js里面的部分内容

dataSource : {
            type : "com.alibaba.druid.pool.DruidDataSource",
            events : {
                create : "init",
                depose : 'close'
            },
            fields : {
                url : {java:"$conf.get('db.url')"},
                username : {java:"$conf.get('db.username')"},
                password : {java:"$conf.get('db.password')"},
                testWhileIdle : true,
                validationQuery : {java:"$conf.get('db.validationQuery')"},
                maxActive : {java:"$conf.get('db.maxActive')"},
                filters : "mergeStat",
                connectionProperties : "druid.stat.slowSqlMillis=2000"
            }
        },

db的配置文件:

db.url=jdbc:oracle:thin:@192.168.140.149:1521:MyDatabase
db.username=ACCount
db.password=123456
db.validationQuery=select 1
db.maxActive=100

@gitleonine1989
非常感谢,确实是,我漏掉了 class12.jar 包。

PS:下面这一句也有问题,在oracle里面这句是不能执行的。。。。弄混了。

db.validationQuery=select 1

别用class12.jar这么老的驱动, 用ojdbc6.jar

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