"Playing" Nice with Oracle - Using Play Framework 2.1 with Oracle

I am throwing together a quickie Play Framework application for a DB process dashboard. I love Play. Its quick, powerful, and does a pretty good job of getting out of your way when you need it to.

But as a cutting edge open source app framework the documentation is sometimes a little behind the curve... Or assumes you are always using h2 for dev and mySQL for production.

Here are some tips on getting your new Play app to play nicely with Oracle via JDBC.

Make the JAR Available to your App

  • In your application directory create a dir called "lib" if there is not one there already.
  • Drop the ojdbc6.jar in this directory.

Configure Your Data Source

In your application.conf use this as an example, substitute for your HOST/PORT/SID/USERNAME/PASSWORD:

Create the Play Evolution table

This table keeps track of evolutions. If you got an ORA-00942 after only doing the previous two steps then this is usually the culprit. Create the following table in your schema:

create table play_evolutions (
  id number not null primary key, 
  hash varchar2(255) not null, 
  applied_at timestamp not null, 
  apply_script clob, 
  revert_script clob, 
  state varchar2(255), 
  last_problem clob

Not using evolutions? Turn 'em off!

If you already have a schema available and don't need to use Play's DB Evolutions to manage your schema, you can turn them off.

In application.conf:


Annotate your eBean Models to use Oracle Objects

If you already have a schema then you may have table names that do not match your class names. Without getting into ORM wars and in the interest of getting something up and running quickly I used the Ebean ORM Persistence Layer. An example of a model class is available here: Address.java. Notice the @Table annotation in the class:

This will allow the table associated with the model class to be different than the name of the class. Check the documentation for your ORM for how to specify this for your model classes.

Oh and don't forget to spin up a eBean server by adding this to application.conf:


Add new comment