Connecting to H2 with DbVisualizer

2,644 views
Skip to first unread message

chungonn

unread,
May 15, 2011, 5:53:11 AM5/15/11
to play-framework
Hi,

I am tried to connect to Play's embedded H2 db using DbVisualizer but
fail. I tried changing Play's H2 settings but didn't help. Connecting
to H2's console is fine though.

Any help on this is greatly appreciated.

Here's my setting in application.conf

%test.jpa.ddl=update
%test.jpa.dialect=org.hibernate.dialect.H2Dialect
%test.db.url=jdbc:h2:mem:play;AUTO_SERVER=TRUE;MODE=MYSQL;LOCK_MODE=0;DB_CLOSE_DELAY=-1
%test.db.driver=org.h2.Driver
%test.db.user=sa
%test.db.pass=

Here's the db.url from DbVisualizer
jdbc:h2:tcp://localhost/mem:play

Below is the error from DbVisualizer
An error occurred while establishing the connection:

Long Message:
Connection is broken: "Connection refused" [90067-149]

Details:
   Type: org.h2.jdbc.JdbcSQLException
   Error Code: 90067
   SQL State: 90067

pablo72

unread,
May 15, 2011, 8:11:03 AM5/15/11
to play-fr...@googlegroups.com
I dont think you can access an in-memory database from an external process. 

But I'm not really sure/ 

Cheers,
Paolo

Pascal Voitot Dev

unread,
May 15, 2011, 8:12:59 AM5/15/11
to play-fr...@googlegroups.com
It should be possible as the H2 is started in server mode in Play afaik!
Pascal

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

chungonn

unread,
May 15, 2011, 12:31:31 PM5/15/11
to play-framework
Hi Paolo and Pascal,

I managed to solve the problem after spending many hours on this
issue. Both of you are right and here is my problem. I can only start
and an embedded server db but not in memory. Hence my url should be

%test.db.url=jdbc:h2:play;AUTO_SERVER=TRUE;MODE=MYSQL;LOCK_MODE=0;DB_CLOSE_DELAY=-1

then I need to connect to the db using info from the .lock.db file. In
my case the url is
jdbc:h2:tcp://
172.20.10.2:49434/12ff45a8d5228ea09fa5b848476c84f20625b0e01fc

Though now I can connect to the play db now but DBVisualizer is
complaining about the missing 'public' schema when i select the
tables. Any thoughts?

Regards
chungonn


On May 15, 8:12 pm, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:

Pascal Voitot Dev

unread,
May 15, 2011, 12:35:39 PM5/15/11
to play-fr...@googlegroups.com
On Sun, May 15, 2011 at 6:31 PM, chungonn <chun...@gmail.com> wrote:
Hi Paolo and Pascal,

I managed to solve the problem after spending many hours on this
issue. Both of you are right and here is my problem. I can only start
and an embedded server db but not in memory. Hence my url should be

%test.db.url=jdbc:h2:play;AUTO_SERVER=TRUE;MODE=MYSQL;LOCK_MODE=0;DB_CLOSE_DELAY=-1

then I need to connect to the db using info from the .lock.db file. In
my case the url is
jdbc:h2:tcp://
172.20.10.2:49434/12ff45a8d5228ea09fa5b848476c84f20625b0e01fc

Though now I can connect to the play db now but DBVisualizer is
complaining about the missing 'public' schema when i select the
tables. Any thoughts?


do you connect using a kind of MYSQL "dialect" ? (not the hibernate meaning here but simply the SQL expected by MYSQL)
 

chungonn

unread,
May 15, 2011, 8:39:43 PM5/15/11
to play-framework
Hi Pascal,

I am using DbVisualizer, I am connecting using Database Type as
'Genric'. Not sure if I have answer your question.

Regards
chungonn

On May 16, 12:35 am, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:

Pascal Voitot Dev

unread,
May 16, 2011, 2:30:04 AM5/16/11
to play-fr...@googlegroups.com
I don't know DBVisualizer much so I can't tell you but what I know is that Play creates an instance of H2 in "MYSQL" mode which trie to mimic MYSQL. So, the SQL used to speak to this DB is not H2 native SQL but "MYSQL" SQL dialect.
Anyway, I'm not sure this is the reason.
Did you investigate in H2 groups directly about this kind of issues?

Pascal

chungonn

unread,
May 17, 2011, 1:24:49 AM5/17/11
to play-framework
I did a cross post at H2 groups and is still waiting for the
response.

After reading your reply, I tried using 'MySQL' database type instead
of 'Generic' and it works!

Thanks.

Regards
chungonn

On May 16, 2:30 pm, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:

Pascal Voitot Dev

unread,
May 17, 2011, 2:35:50 AM5/17/11
to play-fr...@googlegroups.com
On Tue, May 17, 2011 at 7:24 AM, chungonn <chun...@gmail.com> wrote:
I did a cross post at H2 groups and is still waiting for the
response.

After reading your reply, I tried using 'MySQL' database type instead
of 'Generic' and it works!

great :)
I had some recent issues while developing H2 support for Siena with H2 in mode MYSQL. So I can say, it's only a mimic mode, not a exact copy mode ;)
 
regards
pascal

Reply all
Reply to author
Forward
0 new messages