-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Accessing SQLite database inside a JAR file
PostPosted: Tue Apr 07, 2009 1:43 am 
Newbie

Joined: Tue Apr 07, 2009 1:12 am
Posts: 1
Location: Australia
Hi,

I've successfully got Hibernate to access a SQLite database file in a read-only manner. (Used a dialect file freely available on the web and an open source SQLite JDBC driver - problems trying to update the schema, but it does not affect my read only task.)

However, my problem is that I want to stick this sqlite database file inside a JAR file.

The attempted connection info and error reported is shown below. The code works fine if I just have
Code:
<property name="connection.url">jdbc:sqlite:databasefile.sqlite</property>
and put that sqlite file in the Java working directory for the project. ie it's not an issue of the sqlite file or the JAR file being visible to Java.

It seems that you cannot specify a JAR file as a URL in this config file?

Does anyone know of a way around this? Can you programmatically do everything specified in this XML file and at some point then use the JAR URL Connection format that seems to be causing issues when parsed from the XML?

Thanks,

Steve

Hibernate version: 3.3.1.GA (Core)

Database Connection info from hibernate.cfg.xml:
<property name="connection.driver_class">org.sqlite.JDBC</property>
<property name="connection.url">jdbc:sqlite:jar:file://C:/folder/somefile.jar!databasefile.sqlite</property>
<property name="connection.username"></property>
<property name="connection.password"></property>

Relevant trace of the exception that occurs:
2009-04-07 14:57:24,193 WARN (org.hibernate.cfg.SettingsFactory:144) [buildSettings] Could not obtain connection metadata
java.sql.SQLException: path to 'jar:file://C:/folder/somefile.jar!databasefile.sqlite': 'C:\folder\jar:file:' does not exist
2009-04-07 14:57:24,443 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:175) [execute] could not get database metadata
java.sql.SQLException: path to 'jar:file://C:/folder/somefile.jar!databasefile.sqlite': 'C:\folder\jar:file:' does not exist
2009-04-07 14:57:24,506 WARN (org.hibernate.util.JDBCExceptionReporter:100) [logExceptions] SQL Error: 0, SQLState: null
2009-04-07 14:57:24,506 ERROR (org.hibernate.util.JDBCExceptionReporter:101) [logExceptions] path to 'jar:file://C:/folder/somefile.jar!databasefile.sqlite': 'C:\folder\jar:file:' does not exist

Name and version of the database you are using: SQLite version 3.6.11


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.