Maybe you can make your path relative to the user directory as described here:
http://www.h2database.com/html/faq.html#database_files


Am 14. Februar 2018 21:06:34 MEZ schrieb Evan Ruff <evan.r...@gmail.com>:
>Hey guys,
>
>So I'm actually just letting Guice Persist pull it straight out of 
>META-INF/persistence.xml file. 
>
>I'm wondering where I can either change the URL or set it explicitly,
>while 
>still using Guice Persist.
>
>thanks!
>
>E
>
>On Wednesday, February 14, 2018 at 10:58:11 AM UTC-5, Sondre Bjornebekk
>
>wrote:
>>
>> If you always want to use h2, you could just simply build the string
>using 
>>
>https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getenv--?
>>
>> If you wanted to inject different JPA providers, you could certainly
>use 
>> Guice for that (since you posted here) - I have a
>HibernateSessionFactory 
>> that provides a session per request like this:
>>
>> @Provides
>> @RequestScoped
>> private Session provideSession() {
>>
>>
>>
>> And then for my jUnit tests I have:
>>
>> @Provides
>> @Singleton
>> private Session provideSession() {
>>
>>
>> in a
>>
>> public class TestGuiceModule extends AbstractModule
>>
>>
>> Would that fit your use case?
>>
>> Cheers,
>>
>> -S-
>>
>> On Wednesday, February 14, 2018 at 10:38:16 AM UTC, Evan Ruff wrote:
>>>
>>> Hey guys,
>>>
>>> I've got what I think is a pretty straightforward task but I'm
>having a 
>>> little issue figuring out where to attach in my code.
>>>
>>> I've got an embedded H2 database being used in an installed
>application 
>>> to manage state of some objects. I'm using Hibernate as my JPA 
>>> implementation and everything is working great. The one issue I have
>is 
>>> that the path of the database file is set in my URL as:
>>>
>>>
>>>
>jdbc:h2:file:./data/application_db;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;
>>>
>>> which changes depending on how the application is executed. I'd like
>to 
>>> have the database file be written in a location set by an
>environment 
>>> variable, so that I'd have:
>>>
>>> jdbc:h2:file:*$APP_DB_PATH*
>>> /data/application_db;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;
>>>
>>> I've tried several different forms and it doesn't seem to be taking.
>
>>>
>>> Has anyone encountered this and could give me a pointer on how to 
>>> implement?
>>>
>>> Thanks!
>>>
>>> E
>>>
>>
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "google-guice" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to google-guice+unsubscr...@googlegroups.com.
>To post to this group, send email to google-guice@googlegroups.com.
>Visit this group at https://groups.google.com/group/google-guice.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/google-guice/5c35a644-645a-4419-85c3-9a3a159fc87d%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/CC173E92-331F-4CC5-BD39-2F2430BFFF38%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.

Reply via email to