使用grails连接到多个oracle数据源的问题 [英] Issues connecting to more than one oracle datasource using grails

查看:1023
本文介绍了使用grails连接到多个oracle数据源的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这是重复,请原谅我。我已经搜索和搜索。但是我有一些东西,在过去几天里,我欺骗了我。我研究过,没有找到解决我的问题的解决方案。我正在处理一个需要访问多个数据库的应用程序。如果我只做一个数据库,并将它注入到一个datasource对象的代码,它只是正常使用我使用的数据库。但是如果我试图添加另一个数据源,那就是问题开始。我已经尝试添加配置到datasource.groovy,我已经尝试'硬编码'的连接。



硬编码方法 b
$ b

正如你所看到的,我已经尝试使用下面的各种方法,所有的都给了我以下的错误。 ojdbc6.jar加载正确,因为我已经验证通过故意拼写驱动程序类名称并得到类未找到错误。

  import java.sql。* 

def index(){
...
def db = [url:'jdbc:oracle:oci8:@ someotherdatabase.whatever.com',user:'other_user',password:'other_pw',driver:'oracle.jdbc.OracleDriver']
def sql = Sql.newInstance(db.url,db.user,db.password,db.driver)
// Sql.loadDriver(oracle.jdbc.driver.OracleDriver)
// Sql.loadDriver(oracle.jdbc.OracleDriver)
// def sql2 = Sql.newInstance('jdbc:oracle:oci8:@ someotherdatabase.whatever.com','other_user','other_pw','oracle .jdbc.driver.OracleDriver')
// def sql = Sql.newInstance(jdbc:oracle:oci8:@ someotherdatabase.whatever.com,other_user,other_pw,oracle.jdbc.OracleDriver
// DriverManager.registerDriver(new oracle.jdbc.OracleDriver())
// Class.forName(oracle.jdbc.driver.OracleDriver)
//连接conn = DriverManager.getConnection('jdbc:oracle:oci8:@ someotherdatabase.whatever.com','other_user','other_pw')
// Sql sql = new Sql(conn)
...
}

错误:

 错误| 
2014-10-28 11:38:06,766 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - 处理请求时发生SQLException:[GET] / ApplicationPortal / home
无合适的驱动程序发现jdbc:oracle:oci8:@ someotherdatabase.whatever.com。 Stacktrace如下:
消息:找不到适合jdbc的驱动程序:oracle:oci8:@ someotherdatabase.whatever.com
Line |方法
- >> 602 | java.sql.DriverManager中的getConnection
- - - - - - - - - - - - - - - - - - - - - - - - - - -
| 185 | '
|中的getConnection 192 |索引。 。 。 。在com.myapp.HomeController $$ EOu0LeDV
| 200 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter。 。在grails.plugin.cache.web.filter.AbstractFilter
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |跑 。 。 。 。 。 in''
^ 662 |在java.lang.Thread中运行

Datasource.groovy配置方法 p>

我在datasource.groovy中尝试了不同的配置。目前这是它的样子:

  dataSource {
dialect = org.hibernate.dialect.Oracle10gDialect
driverClassName ='oracle.jdbc.driver.OracleDriver'
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = true
validationQuery =SELECT 1 from dual
}
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class ='net.sf.ehcache.hibernate.EhCacheRegionFactory'
showsql = true
}

environment {
development {
dataSource {
url =jdbc:oracle:oci:@ database.whatever.com
username =data_user
password =some_pw
}
dataSource_task {
url =jdbc:oracle:oci8:@ someotherdatabase.whatever.com
username =other_user
password =other_pw
}
}

}

我得到的错误。我不知道为什么它试图使用h2数据库。我需要它连接到oracle数据库。

 错误| 
2014-10-29 13:30:53,500 [localhost-startStop-1]错误pool.ConnectionPool - 无法创建池的初始连接。
消息:Driver:org.h2.Driver@42b1b290为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
Line |方法
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
错误|
2014-10-29 13:30:53,547 [localhost-startStop-1]错误pool.ConnectionPool - 无法创建池的初始连接。
消息:Driver:org.h2.Driver@2d2c1472为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
Line |方法
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
错误|
2014-10-29 13:30:53,621 [localhost-startStop-1]错误pool.ConnectionPool - 无法创建池的初始连接。
消息:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
Line |方法
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
错误|
2014-10-29 13:30:53,634 [localhost-startStop-1] ERROR context.GrailsContextLoader - 初始化应用程序时出错:创建名为transactionManager_task的bean时出错:设置时不能解析bean'sessionFactory_task'的引用bean属性'sessionFactory';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory_task'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties_task'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties_task'的bean时出错:使用键[hibernate.dialect]设置bean属性'properties'时,无法解析对bean'dialectDetector_task'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector_task'的bean时出错:调用init方法失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常为java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
消息:创建名为transactionManager_task的bean时出错:设置bean属性'sessionFactory'时,无法解析对bean'sessionFactory_task'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory_task'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties_task'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties_task'的bean时出错:使用键[hibernate.dialect]设置bean属性'properties'时,无法解析对bean'dialectDetector_task'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector_task'的bean时出错:调用init方法失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
Line |方法
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。 java.lang.Thread
由BeanCreationException引起:创建名为'sessionFactory_task'的bean时出错:在设置bean属性'hibernateProperties'时,无法解析对'hibernateProperties_task'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties_task'的bean时出错:使用键[hibernate.dialect]设置bean属性'properties'时,无法解析对bean'dialectDetector_task'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector_task'的bean时出错:调用init方法失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
由BeanCreationException引起:创建名为'hibernateProperties_task'的bean时出错:使用key [hibernate.dialect]设置bean属性'properties'时,无法解析对bean'dialectDetector_task'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector_task'的bean时出错:调用init方法失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。 in java.lang.Thread
由BeanCreationException引起:创建名为dialectDetector_task的bean时出错:调用init方法失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
引起的MetaDataAccessException:错误时提取DatabaseMetaData;嵌套异常是java.sql.SQLException:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
由SQLException驱动:Driver:org.h2.Driver@17898b92为URL返回null:jdbc:oracle:oci8:@ someotherdatabase.whatever.com
- >> 303 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 |在java.util.concurrent.FutureTask中运行
| 895 | runTask在java.util.concurrent.ThreadPoolExecutor $ Worker
|中918 |运行在''
^ 662 |跑 。 。在java.lang.Thread
错误|
Forked Grails VM退出时出错

安装程序:
Grails 2.3.7
Oracle 11g



编辑:
数据源方法的问题不在于我使用了多少个数据源。我跟名字有关。如果我只是使用一个datasouce作为datasource_other,它会抛出的错误。但数据源工作。

解决方案

就数据源配置方法而言,这是一个骨头的错误。我没有将driverClassName添加到dataSource_task中。

  dataSource_task {
url =jdbc:oracle:oci8: @ someotherdatabase.whatever.com
username =other_user
password =other_pw
driverClassName ='oracle.jdbc.driver.OracleDriver'//< - it need this
}



我还是想知道为什么hardcode方法不工作。 / p>

If this is a duplicate, please forgive me. I have searched and searched. But I have something that's been bugging me for the past couple of days. I have researched and haven't found a solution that solves my issues. I'm working on an application that will need to access multiple databases. If I do just one database and inject it into the code with a datasource object, it does just fine with whatever database I use. But if I try to add another datasource, that's when the problems start. I have tried adding the configuration to datasource.groovy and I've tried 'hardcoding' the connection.

Hardcode method

As you can see, I've tried using the various methods below and ALL have given me the error following. The ojdbc6.jar loads correctly, because I have verified by deliberately misspelling the driver class name and got the class not found error.

import java.sql.*

def index(){
    ...
    def db = [url:'jdbc:oracle:oci8:@someotherdatabase.whatever.com', user:'other_user', password:'other_pw', driver:'oracle.jdbc.OracleDriver']
    def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
    //      Sql.loadDriver("oracle.jdbc.driver.OracleDriver")
    //      Sql.loadDriver("oracle.jdbc.OracleDriver")
    //      def sql2 = Sql.newInstance('jdbc:oracle:oci8:@someotherdatabase.whatever.com','other_user','other_pw','oracle.jdbc.driver.OracleDriver')
    //      def sql = Sql.newInstance("jdbc:oracle:oci8:@someotherdatabase.whatever.com", "other_user", "other_pw", "oracle.jdbc.OracleDriver")
    //      DriverManager.registerDriver(new oracle.jdbc.OracleDriver())
    //      Class.forName("oracle.jdbc.driver.OracleDriver")
    //      Connection conn = DriverManager.getConnection('jdbc:oracle:oci8:@someotherdatabase.whatever.com','other_user','other_pw')
    //      Sql sql = new Sql(conn)
    ...
}

error:

Error |
2014-10-28 11:38:06,766 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver  - SQLException occurred when processing request: [GET] /ApplicationPortal/home
No suitable driver found for jdbc:oracle:oci8:@someotherdatabase.whatever.com. Stacktrace follows:
Message: No suitable driver found for jdbc:oracle:oci8:@someotherdatabase.whatever.com
   Line | Method
->> 602 | getConnection in java.sql.DriverManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   185 | getConnection in     ''
|   192 | index . . . . in com.myapp.HomeController$$EOu0LeDV
|   200 | doFilter      in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|    63 | doFilter . .  in grails.plugin.cache.web.filter.AbstractFilter
|   895 | runTask       in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run . . . . . in     ''
^   662 | run           in java.lang.Thread

Datasource.groovy configuration method

I have tried different configurations in datasource.groovy. Currently this is what it looks like:

dataSource {
    dialect = org.hibernate.dialect.Oracle10gDialect
    driverClassName = 'oracle.jdbc.driver.OracleDriver'
    pooled = true
    properties {
        maxActive = -1
        minEvictableIdleTimeMillis=1800000
        timeBetweenEvictionRunsMillis=1800000
        numTestsPerEvictionRun=3
        testOnBorrow=true
        testWhileIdle=true
        testOnReturn=true
        validationQuery="SELECT 1 from dual"
    }
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    showsql = true
}

environments {
    development {
        dataSource {
            url = "jdbc:oracle:oci:@database.whatever.com"
            username="data_user"
            password = "some_pw"
        }
        dataSource_task {
            url = "jdbc:oracle:oci8:@someotherdatabase.whatever.com"
            username="other_user"
            password = "other_pw"
        }
    }

}

And I'm getting the error. I don't know why it's trying to use the h2 database. I need it to connect to the oracle database.

Error |
2014-10-29 13:30:53,500 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.h2.Driver@42b1b290 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Error |
2014-10-29 13:30:53,547 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.h2.Driver@2d2c1472 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Error |
2014-10-29 13:30:53,621 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Error |
2014-10-29 13:30:53,634 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManager_task': Cannot resolve reference to bean 'sessionFactory_task' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_task': Cannot resolve reference to bean 'hibernateProperties_task' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties_task': Cannot resolve reference to bean 'dialectDetector_task' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector_task': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
Message: Error creating bean with name 'transactionManager_task': Cannot resolve reference to bean 'sessionFactory_task' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_task': Cannot resolve reference to bean 'hibernateProperties_task' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties_task': Cannot resolve reference to bean 'dialectDetector_task' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector_task': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory_task': Cannot resolve reference to bean 'hibernateProperties_task' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties_task': Cannot resolve reference to bean 'dialectDetector_task' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector_task': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'hibernateProperties_task': Cannot resolve reference to bean 'dialectDetector_task' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector_task': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dialectDetector_task': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by SQLException: Driver:org.h2.Driver@17898b92 returned null for URL:jdbc:oracle:oci8:@someotherdatabase.whatever.com
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   662 | run . .  in java.lang.Thread
Error |
Forked Grails VM exited with error

Setup: Grails 2.3.7 Oracle 11g

EDIT: The problem with the datasource method is not with how many datasources I use. I has to do with the name. If I just use one datasouce as datasource_other, it will throw the error. But datasource works.

解决方案

As far as the datasource configuration method is concerned, I figured that one. It was a boneheaded mistake. I didn't add the driverClassName to the dataSource_task.

dataSource_task {
    url = "jdbc:oracle:oci8:@someotherdatabase.whatever.com"
    username="other_user"
    password = "other_pw"
    driverClassName = 'oracle.jdbc.driver.OracleDriver'// <- it needed this
}

I'd still like to know why the hardcode method doesn't work tho.

这篇关于使用grails连接到多个oracle数据源的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆