db.default.url="jdbc:h2:mem:play;MODE=PostgreSQL;LOCK_MODE=0" does not have any effect

3,911 views
Skip to first unread message

Mani Sarkar

unread,
Nov 11, 2013, 6:19:43 PM11/11/13
to play-fr...@googlegroups.com
Hi,

I have the below setting in the application.conf file 

db.default.url="jdbc:h2:mem:play;MODE=PostgreSQL;LOCK_MODE=0"

and when I run play using 

$ play run

I see the below line in the log file 

database [default] connected at jdbc:h2:mem:play

instead of seeing

database [default] connected at jdbc:h2:mem:play;MODE=PostgreSQL;LOCK_MODE=0

I also see when I switch to the on-disk db which is a PostgreSQL database, the 1.sql file is amended with PostgreSQL style formatting and the moment I switch back to the above settings (in-memory) it reverts to its original sql. I think this is happening due to the fact that the PostgreSQL mode isn't taking effect.

Can anyone suggest what I'm not doing or doing wrong? Any help will be appreciated!

Cheers,
mani

James Roper

unread,
Nov 11, 2013, 11:14:31 PM11/11/13
to play-framework
The URL you are seeing there is the URL that the database returns when you invoke java.sql.Connection.getMetaData().getURL().  What gets returned here is all dependent on the database driver, and it seems in this case, H2 simply doesn't include the parameters in the URL that it returns.  I don't know why that is.

As for the SQL generation, this is based on what ebean detects, and the way ebean detects the database is by asking the database driver for the database name, for h2 I guess this is returning h2, for postgres it's returning postgres.  You can manually tell ebean which database platform it's using by creating conf/ebean.properties, and putting this in there:

ebean.default.databasePlatformName=postgres83

I don't know why it has to be postgres83, and not some other version of postgres or just some string without the version, but that's what ebean wants:



--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
James Roper
Software Engineer

Typesafe – Build reactive apps!
Twitter: @jroper

Filip Dziedzic

unread,
Nov 12, 2013, 5:44:59 PM11/12/13
to play-fr...@googlegroups.com
Are you using Anorm or maybe Slick? If the latter, perhaps you are importing wrong driver (for wrong database engine)?

Mani Sarkar

unread,
Nov 18, 2013, 6:31:45 PM11/18/13
to play-fr...@googlegroups.com
Hi Thanks for your response, not using Anorm or Slick - rather H2 does that answer your question?

Cheers
mani

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/jXO9KHGqFa8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Twitter: @theNeomatrix369          Blog: http://neomatrix369.wordpress.com
JUG activity: LJC Advocate (@adoptopenjdk & @adoptajsr programs)

Don't chase success, rather aim for "Excellence", and success will come chasing after you!

Filip Dziedzic

unread,
Nov 19, 2013, 7:03:34 AM11/19/13
to play-fr...@googlegroups.com
Anorm or Slick are not databases itself, but they are libraries that provide access to databases. I asked you about that, because when I used Slick (http://slick.typesafe.com/) in one of my project, I also wanted to use H2 in memory db in the Postgres mode. In that case I used wrong import statement in my code (I imported wrong driver, for H2 not for Postgres database) and that was why my generated *.sql files were formatted in H2 manner instead of Postgres.

Greetings,
Filip


2013/11/19 Mani Sarkar <sadh...@gmail.com>
Reply all
Reply to author
Forward
0 new messages