Hi,
Try using an absolute path in the database URL:
jdbc:h2:file:/data/db/mydb
or a path relative to the current user home directory:
jdbc:h2:file:~/db/mydb
Regards,
Thomas
On Tuesday, April 1, 2014, <[email protected]> wrote:
> Hi all, I'm sure I'm overlooking something simple. Here's the situation:
>
> I'm connecting to an embedded h2 file database using a connection string
> like this:
>
> jdbc:h2:file:db/mydb
>
> This code is a snippet from a class called LinkDao.update() method. It
> uses spring JdbcDaoSupport (and JdbcTemplate) to update a h2 database like
> so:
>
> int result = getJdbcTemplate().update(sql, values);
> if(result == 1) {
> return true;
> } else {
> return false;
> }
>
> This is a webapp that crawls some web pages and attempts to find urls.
> When it finds a url, it inserts a row into the h2 database into a table
> named "LINKS". If a row already exists for that url, it does an update.
> This part of the code runs as a quartz job. It's very basic and works fine.
>
> Another part of the code provides a rest api that allows for updating
> information about the links. The strange part is that when the rest api
> code calls the exact same LinkDao.update() method, the update doesn't
> appear to persist?! I can even debug the code during runtime. During the
> debug session, the update appears to succeed, but then when I query the
> data, it doesn't seem like the update happened.
>
> I've tried setting AUTOCOMMIT in the connection string like this:
>
> jdbc:h2:file:db/mydb;AUTOCOMMIT=ON
>
> I feel like I'm missing something super simple. Maybe I have to explicitly
> call commit after each update or something? Since this is a webapp, there
> are multiple threads accessing the db, maybe I need to configure h2 to
> handle updates from multiple threads?
>
> Any ideas? If not, then I'm sure it's something silly I'm missing in my
> code (unrelated to h2). Thanks for your help,
>
> Dave
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> [email protected]<javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');>
> .
> To post to this group, send email to
> [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
> .
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.