0

この問題を解決するために多くの時間を費やしました。私は GRAILS と GROOVY の初心者です。「tms_dev」という名前の従来の Oracle データベース スキーマがあります。このスキーマには、いくつかのテーブル (checktypes テーブルなど) があります。また、ドメイン クラス Checktype と ChecktypesController クラス (GRAILS によって生成されたコントローラー) もあります。

このクラスには list メソッドがあります。

デフリスト(整数最大) {

params.max = Math.min(max ?: 10, 100)
[checktypesInstanceList: Checktypes.list(params), checktypesInstanceTotal: Checktypes.count()]

}

また、そのようなコンテンツでOracleと連携するようにDatasource.groovyファイルを構成しました

dataSource {
    pooled = true
    driverClassName = "oracle.jdbc.OracleDriver"
    dialect = "org.hibernate.dialect.Oracle10gDialect"
    username = "TMS_DEV"
    password = "password"
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:oracle:thin:@server_name:1522:sid_name"
        }
    }
production {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:oracle:thin:@server_name:1522:sid_name"
        }
    }

アプリケーションを実行します。メインページの「tst7.ChecktypesController」参照をクリックします。

その結果、例外があります:

| Error 2012-08-27 14:41:03,469 [http-bio-8080-exec-9] ERROR util.JDBCExceptionReporter  - Table "CHECKTYPES" not found; SQL statement:
select * from ( select this_.CHECKTYPECODE as CHECKTYP1_21_0_, this_.active as active21_0_, this_.availabilitychecktype as availabi3_21_0_, this_.checktypecode as checktyp1_21_0_, this_.checktypedescr as checktyp4_21_0_, this_.TARGETTYPECODE as TARGETTY5_21_0_ from CHECKTYPES this_ ) where rownum <= ? [42102-164]
| Error 2012-08-27 14:41:03,547 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver  - JdbcSQLException occurred when processing request: [GET] /Tst7/checktypes/list
Table "CHECKTYPES" not found; SQL statement:
select * from ( select this_.CHECKTYPECODE as CHECKTYP1_21_0_, this_.active as active21_0_, this_.availabilitychecktype as availabi3_21_0_, this_.checktypecode as checktyp1_21_0_, this_.checktypedescr as checktyp4_21_0_, this_.TARGETTYPECODE as TARGETTY5_21_0_ from CHECKTYPES this_ ) where rownum <= ? [42102-164]. Stacktrace follows:
Message: Table "CHECKTYPES" not found; SQL statement:
select * from ( select this_.CHECKTYPECODE as CHECKTYP1_21_0_, this_.active as active21_0_, this_.availabilitychecktype as availabi3_21_0_, this_.checktypecode as checktyp1_21_0_, this_.checktypedescr as checktyp4_21_0_, this_.TARGETTYPECODE as TARGETTY5_21_0_ from CHECKTYPES this_ ) where rownum <= ? [42102-164]
    Line | Method
->>  329 | getJdbcSQLException       in org.h2.message.DbException
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    169 | get                       in     ''
|    146 | get . . . . . . . . . . . in     ''
|   4753 | readTableOrView           in org.h2.command.Parser
|   1080 | readTableFilter . . . . . in     ''
|   1686 | parseSelectSimpleFromPart in     ''
|   1793 | parseSelectSimple . . . . in     ''
|   1680 | parseSelectSub            in     ''
|   1523 | parseSelectUnion . . . .  in     ''
|   1022 | readTableFilter           in     ''
|   1686 | parseSelectSimpleFromPart in     ''
|   1793 | parseSelectSimple         in     ''
|   1680 | parseSelectSub . . . . .  in     ''
|   1523 | parseSelectUnion          in     ''
|   1511 | parseSelect . . . . . . . in     ''
|    405 | parsePrepared             in     ''
|    279 | parse . . . . . . . . . . in     ''
|    251 | parse                     in     ''
|    217 | prepareCommand . . . . .  in     ''
|    415 | prepareLocal              in org.h2.engine.Session
|    364 | prepareCommand . . . . .  in     ''
|   1121 | prepareCommand            in org.h2.jdbc.JdbcConnection
|     71 | <init> . . . . . . . . .  in org.h2.jdbc.JdbcPreparedStatement
|    267 | prepareStatement          in org.h2.jdbc.JdbcConnection
|    281 | prepareStatement . . . .  in org.apache.commons.dbcp.DelegatingConnection
|    313 | prepareStatement          in org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
|     55 | <init> . . . . . . . . .  in grails.orm.PagedResultList
|     45 | list                      in tst7.ChecktypesController
|    195 | doFilter . . . . . . . .  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter                  in grails.plugin.cache.web.filter.AbstractFilter
|   1110 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
|    603 | run                       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . . . . . . . in java.lang.Thread

次に、リストメソッドで直接Oracle接続を作成しようとしました

def list(Integer max) {

        def sql = Sql.newInstance("jdbc:oracle:thin:@server_name:1522:instance_name", "TMS_DEV",
            "password", "oracle.jdbc.driver.OracleDriver")
        sql.eachRow("select * from Dbdrivers"){
            println it.dbdrivercode
        }
}

アプリケーションを実行するより。その結果、println it.dbdrivercode - 正常に動作します (CONNECTION WORKS!!!)。

この問題で最も奇妙なのは、例外が h2 (メモリ データベースの H2) クラス (org.h2.jdbc.JdbcConnection 、org.h2.jdbc.JdbcConnection など) によって生成されることです。

4

2 に答える 2

2

環境ブロックの外側では本番および開発ブロックが無視されるため、デフォルトで H2 ドライバーを使用しています。

于 2012-08-28T23:28:28.213 に答える
1

アプリケーションキャッシュの問題のように聞こえます。アプリを実行する前に grails clean を実行してみてください。

于 2012-08-27T17:47:43.210 に答える