Hi,

The problem is most likely the ".h2.db":

>      File file = File.createTempFile(dbname, ".h2.db");
>      ds.setUrl("jdbc:h2:file:" + file.getAbsolutePath());

With dbname = "/data/test", the URL would become:
jdbc:h2:file:/data/test.h2.db
which would try to open the file:
/data/test.h2.db.h2.db (twice the ".h2.db" suffix).
This file doesn't exist, so it's created (creating a new database).

Instead, I suggest to use:

File file = File.createTempFile(dbname, ".h2.db");
ds.setUrl("jdbc:h2:file:" + System.getProperty("java.io.tmpdir") + "/"
+ dbname);

Or something similar.

Note to self: If the exception is "Table ... not found", then in many
cases the database URL is wrong. Maybe it makes sense to add "(this
database is empty)" to the error message if the database is empty, so
that people understand what could be the problem. Or even: "(this
database is empty - did you open the right database?)".

Regards,
Thomas

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

Reply via email to