Reputation: 325
I have been trying since many days to connect to Oracle database using Play 2.4 framework, but all my attempts are in vain. So, seeking some solution for this.
I have tried the following configurations in application.conf
, but none worked:
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.username=user_name
db.default.password=password
1) db.default.url="jdbc:oracle:thin:@host_name:host_port:sid"
2) db.default.url="jdbc:oracle:thin://@host_name:host_port/sid"
3) db.default.url="jdbc:oracle:thin://host_name:host_port/sid"
4) db.default.url="jdbc:oracle:thin:@host_name:host_port:sid"
db.default.host=host_name
5) db.default.url="jdbc:oracle:thin://@host_name:host_port/sid"
db.default.host=host_name
6) db.default.url="jdbc:oracle:thin://host_name:host_port/sid"
db.default.host=host_name
Below is the exception which I am getting in every case:
CreationException: Unable to create injector, see the following errors: 1) Error in custom provider, Configuration error: Configuration error[Cannot connect to database [default]] while locating play.api.db.DBApiProvider while locating play.api.db.DBApi for field at play.api.db.NamedDatabaseProvider.dbApi(DBModule.scala:80) while locating play.api.db.NamedDatabaseProvider at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) at play.api.db.DBModule$$anonfun$namedDatabaseBindings$1.apply(DBModule.scala:34): Binding(interface play.api.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget(play.api.db.NamedDatabaseProvider@5968e9a8)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) Caused by: Configuration error: Configuration error[Cannot connect to database [default]] at play.api.Configuration$.configError(Configuration.scala:178) at play.api.Configuration.reportError(Configuration.scala:829) 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:318) 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)
Upvotes: 1
Views: 858
Reputation: 325
Thanks everyone for looking at my questions but finally referring to online posts and play 2.4 documentations, below is the answer to this issue:
a) Url format for oracle will be as below:
db.default.url="jdbc:oracle:thin:@host_name:host_port:sid"
b) Add property as:
db.default.hikaricp.connectionTestQuery="SELECT 1 FROM DUAL"
# above query will be used to check connection, this is required.
Thanks, Pradeep Sharma
Upvotes: 2