Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver grails

将ojdbc14.jar加到grails项目中的lib下,将conf包下的DataSource.groovy文件改为dataSource {

    pooled = true
    driverClassName = "oracle.jdbc.driver.OracleDriver"
    username = "scott"
    password = "xx"
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:oracle:thin:@localhost:1521:orcl"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:oracle:thin:@localhost:1521:orcl"
        }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:oracle:thin:@localhost:1521:orcl"
            pooled = true
            properties {
               maxActive = -1
               minEvictableIdleTimeMillis=1800000
               timeBetweenEvictionRunsMillis=1800000
               numTestsPerEvictionRun=3
               testOnBorrow=true
               testWhileIdle=true
               testOnReturn=true
               validationQuery="SELECT 1"
            }
        }
    }
}

 运行run as grails command(run-app)后提示Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver

解决方法是(通过stackoverflow找到答案)

   右击项目-grails tools-open gails command prompt(alt+shift+ctrl+G) 输入clean  然后输入compile --refresh-dependencies

  此时再运行项目,并没有报错,在浏览器能正常打开 http://localhost:8080/testgrails说明项目运行成功

在pl/sql查看项目中的表是否存在于oracle数据库中

 

  显示表:
select  * from tab                
显示表结构:
   select   *   from   user_tab_columns   where   table_name   =   upper('race')   在sqlplus输入desc race即可
 

 

你可能感兴趣的:(oracle)