Hi,

See the documentation at Features / Read Only Databases in Zip or Jar File.

Regards,
Thomas

On Thursday, May 31, 2012, Ryan How wrote:

> I'm not sure on that sorry. What is the full exception? A NPE sounds a bit
> odd, I would have thought you'd get something a bit more informative.
>
> On 31/05/2012 2:44 AM, bee vo wrote:
>
>> If we were to assume that my data.h2.db is in my data.jar file which
>> is in my home directory:
>> So because a jar file is a zip, does that mean that:
>> ssConnection = new SSConnection("jdbc:h2:zip:~/
>> suppliers_and_parts.jar!/**suppliers_and_parts", "sa", "");
>> should get me connected? Every time I've tried that it gives me a null
>> pointer exception because it is more than
>> likely looking for a .zip file. I've tried changing it to
>> "jdbc:h2:jar" and "jdbc:h2:file" but it gives me an exception
>> saying that it could not load properties.
>>
>> Thanks for your help by the way.
>> On May 30, 11:44 am, Ryan How<[email protected]>  wrote:
>>
>>> I remember this coming up before a while ago (but I can't seem to find
>>> it).
>>>
>>> I think you have to get the path of the jar file and then open it in h2
>>> as you would a zip file, giving it the full path (or relative to the
>>> current working directory).
>>>
>>> So you have to use some classloader magic to get the jar file.
>>>
>>> http://stackoverflow.com/**questions/320542/how-to-get-**
>>> the-path-of-a-ru.<http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-ru.>
>>> ..
>>>
>>> Then feed that into the h2 connection string
>>>
>>> But there might be a better way :).
>>>
>>> On 30/05/2012 11:51 PM, bee vo wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>  Yes, I am trying to make a connection to a DB inside the same jar the
>>>> java classes which make the connection will be in.
>>>> On May 30, 10:04 am, Ryan How<[email protected]>    wrote:
>>>>
>>>>> A jar is a zip file :)
>>>>> Do you mean access it via classpath rather than naming the zip/jar
>>>>> file?
>>>>> On 30/05/2012 10:44 PM, bee vo wrote:
>>>>>
>>>>>> Hey, is there a way to make a connection to a db file that is inside a
>>>>>> jar? I know that H2 has a feature that allows connection to a db
>>>>>> inside of zip file but how would I get a connection to a db file
>>>>>> inside a jar?
>>>>>>
>>>>>
>
> --
> 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 <http://groups.google.com/group/h2-database?hl=en>
> .
>
>

-- 
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