播放框架2.5.10中的Oracle数据库连接

时间:2017-03-04 14:49:37

标签: playframework-2.5

我无法在play框架中连接oracle数据库。     我按照以下步骤操作:     application.conf文件中的数据库配置如下:             default.driver = oracle.jdbc.driver.OracleDriver             default.url =" JDBC:预言:瘦:@localhost:1521:XE"             default.username =用户名             default.password =密码              - >在项目的lib文件夹中添加了ojdbc14.jar     使用网址http://localhost:9000点击浏览器     我收到以下错误:             无法连接数据库[默认]     异常如下所示:

        [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.

1 个答案:

答案 0 :(得分:0)

基本上,问题是ojdbc14.jar不支持与Play Framework的Oracle连接。

我尝试使用ojdbc6 for Oracle 11g,但它确实有效。