2017-03-04 71 views
0

我無法在播放框架中連接Oracle數據庫。 步驟如下: 配置application.conf文件中的數據庫如下: default.driver = oracle.jdbc.driver.OracleDriver default.url =「jdbc:oracle:thin:@localhost:1521:XE」 default.username =用戶名 default.password =密碼 - >添加ojdbc14.jar的在lib文件夾中的項目 同時擊中網址爲http://localhost:9000 我收到以下錯誤的瀏覽器: 無法連接到數據庫[默認] 例外在控制檯上如下所示:Oracle數據庫連接在播放框架2.5.10

 [error] c.z.h.p.PoolBase - HikariPool-1 - Failed to execute isValid() for connection, configure connection test query. (oracle.jdbc.driver.T4CConnection.isValid(I)Z) 
     [info] application - Creating Pool for datasource 'default' 
     [error] c.z.h.p.PoolBase - HikariPool-2 - Failed to execute isValid() for connection, configure connection test query. (oracle.jdbc.driver.T4CConnection.isValid(I)Z) 
     [error] application - 

     ! @738nhifg4 - Internal server error, for (GET) 

     play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]] 
       at play.api.Configuration$.configError(Configuration.scala:154) 
       at play.api.Configuration.reportError(Configuration.scala:806) 
       at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:48) 
       at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) 
       at scala.collection.immutable.List.foreach(List.scala:381) 
       at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42) 
       at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72) 
       at play.api.db.DBApiProvider.get(DBModule.scala:62) 
       at play.api.db.DBApiProvider.get(DBModule.scala:58) 
       at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) 
     Caused by: play.api.Configuration$$anon$1: Configuration error[Failed to initialize pool: oracle.jdbc.driver.T4CConnection.isValid(I)Z] 
       at play.api.Configuration$.configError(Configuration.scala:154) 
       at play.api.PlayConfig.reportError(Configuration.scala:996) 
       at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:70) 
       at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) 
       at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) 
       at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) 
       at play.api.db.DefaultDatabase.getConnection(Databases.scala:142) 
       at play.api.db.DefaultDatabase.getConnection(Databases.scala:138) 
       at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44) 
       at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) 
     Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: oracle.jdbc.driver.T4CConnection.isValid(I)Z 
       at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:512) 
       at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:105) 
       at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71) 
       at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:58) 
       at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54) 
       at scala.util.Try$.apply(Try.scala:192) 
       at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) 
       at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) 
       at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) 
       at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) 
     Caused by: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z 
       at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:400) 
       at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:375) 
       at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:346) 
       at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:506) 
       at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:105) 
       at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71) 
       at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:58) 
       at play.api.db.HikariCPConnectionPool$$anonfun$1.appl`enter code here`y(HikariCPModule.scala:54) 
       at scala.util.Try$.apply(Try.scala:192) 
       at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) 


    any advice will be appreciated. 

回答

0

本質上,問題是Oracle連接ojdbc14.jar不支持Play Framework。我試過ojdbc6 for Oracle 11g,它工作。