How to connect to Oracle 11g database using Slick via Play 2/TypeSafe Activator?

2.6k views Asked by At

I am new to Scala and the Play 2 framework. I have a working Oracle 11g database and would like a template to use for connecting to the database using Slick from Play 2.

Can anyone provide a sample Scala file that just connects to an Oracle 11g database and output the table values? Once I'm connected I think I'll be comfortable learning Slick and the Play 2 Framework. I understand there are multiple files that need to be edited such as the build.sbt or build.scala file for dependencies and imports into the application file, however I don't understand how it all works.

I'm looking for a breakdown of the process step by step to get me connected to my Oracle 11g database.

2

There are 2 answers

0
Dmitri B On

Sorry I cant provide step-by step instructions as I do not use play. For commercial sql-databases you need to add slick extensions to your build. The package is closed source and non-free for production environment. I use it with db2 and it is fairly straight forward

http://slick.typesafe.com/doc/1.0.0/extensions.html

0
Turgay Kivrak On

You can use a play slick sample application from here :

https://github.com/freekh/play-slick/tree/master/samples/play-slick-sample

The sample application here uses h2 database. But you can change it to Oracle by the following steps:

  • Add Oracle driver as dependecy in project / Build.scala
  • Change db connection settings in conf / application.conf
  • Create the required table (cat, see models / Cat.scala ) in the Oracle database.