Cannot get connection

77 views
Skip to first unread message

choces

unread,
Sep 9, 2012, 3:32:55 PM9/9/12
to h2-da...@googlegroups.com
I've run into a trouble after switching from 166 to 168 version

The url I use is as follows: "jdbc:h2:h2/jplaydb"

Under 166 I get a connection w/o any trouble, and the database works perfectly.
Soon after switching to either 168, or to the recent 169, w/o any changes in my codebase, I don't get a connection anymore.

I've tried to use "jdbc:h2:file:h2/jplaydb" just in case, with no luck.

I'm running it under JavaSE 1.7u7 either case.

Brian

unread,
Sep 17, 2012, 7:51:37 PM9/17/12
to h2-da...@googlegroups.com
Can you provide the error message?  Or was the data just not there?
I see you're using a relative path for the file - so the actual location of the file H2 is using would change depending on where (which working directory) your program is launched from.

Carlos Hoces

unread,
Sep 18, 2012, 2:12:41 AM9/18/12
to h2-da...@googlegroups.com
There are no error messages at all: the connection returned from the DriverManager is null.
Yes, I use a relative path. This works perfectly under version 166 and before: if the folder does not exist, it is created by H2 engine, otherwise it's used.
None of this happens with versions 168 and 169: no folder creation, no database creation. Even if the folder and database exists, it's no addressed at all.

2012/9/18 Brian <iwo...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/e8e05JjMoxIJ.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.



--
Carlos Hoces

Thomas Mueller

unread,
Sep 19, 2012, 1:42:33 PM9/19/12
to h2-da...@googlegroups.com
Hi,

There are no error messages at all: the connection returned from the DriverManager is null.

Could you debug the DriverManager? That sounds very strange.

Regards,
Thomas

Carlos Hoces

unread,
Sep 19, 2012, 3:15:18 PM9/19/12
to h2-da...@googlegroups.com
I've tried to debug it, but I cannot get significant results; maybe due to JDK sources not being compiled with -g option (as NetBeans Debugger points to)

I've done some more testing, with different uri settings, under 168:

jdbc:h2:~/h2/jplaydb works perfectly. The folder and database was created in user.home as expected.

jdbc:h2:/h2/jplaydb works perfectly.The folder and database was created in the root of the hard disk partition, where the application gets launched from. I don't know if this is the expected behavior, but it works at least.

jdbc:h2:h2/jplaydb doesn`t work at all! It should create the folder and the database under user.dir as in prevoius H2 versions, I guess. No hope! Here is when I get the connection null.

The above uri works perfectly under 166.

You bet how strange all this sounds to me! ;)

2012/9/19 Thomas Mueller <thomas.to...@gmail.com>

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

Thomas Mueller

unread,
Sep 30, 2012, 4:36:35 PM9/30/12
to h2-da...@googlegroups.com
Hi,

> jdbc:h2:h2/jplaydb doesn`t work at all! It should create the folder and the database under user.dir as in prevoius H2 versions, I guess. No hope! Here is when I get the connection null.

In this case, the database file should be created relative to the current working directory (see the docs), not relative to the user.dir. This always was the case for H2 (even in older versions). However, there is an exception if you use the system property h2.baseDir, in this case it is created relative to this directory. But in any case the connection returned by DriverManager is not null; either it works or it throws an exception (for me).

Regards,
Thomas

Carlos Hoces

unread,
Sep 30, 2012, 5:11:44 PM9/30/12
to h2-da...@googlegroups.com
Hi,

user.dir ----> User's current working directory
so I don't quite understand why you seem to distinguish between them.

Either case, I still do not understand why it works as expected under 166 and before, and fails under 168/169
It looks like either a bug in those later versions, or a behaviour change in the H2 specs.

I will try asap that  h2.baseDir system property I wasn't aware of until now, and see what happens.

Regards,
Carlos


2012/9/30 Thomas Mueller <thomas.to...@gmail.com>

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

Thomas Mueller

unread,
Oct 30, 2012, 3:46:19 AM10/30/12
to h2-da...@googlegroups.com
Hi,

I'm sorry, I confused user.dir with user.home. You are right, the database should be created there. It does in my case.

Regards,
Thomas
Reply all
Reply to author
Forward
0 new messages