I am using a H2 persistent database in a spring environment with the following persistence.xml in META-INF
<persistence xmlns="http://..." xmlns:xsi="http://..." xsi:schemaLocation="http://..." version="1.0"> <persistence-unit name="clubdbPU" transaction-type="RESOURCE_LOCAL"> <class>...</class> . . . <class>...</class> <properties> <property name="hibernate.connection.url" value="jdbc:h2:~/.club/ clubdb;CACHE_TYPE=SOFT_LRU;INIT=runscript from 'classpath:create.sql'"/ > <property name="hibernate.connection.username" value="app" /> <property name="hibernate.connection.password" value="app" /> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.connection.driver_class" value="org.h2.Driver"/> </properties> </persistence-unit> </persistence> It all works fine if i create the database with H2 console and leave the INIT part in the connection-url. It also works fine if i add a the INIT part in the connection-url with an absolut path like ~/INITSCRIPT.sql or C:\scripts\initscript.sql BUT as soon as i change the path to a relative (starting without a / or drive letter) or like in the example above with classpath: as advised on stackoverflow. It stops working for different reasons. If i try it with the relative path i get a FileNotFoundException, because i could not figure out where i should put the file respectively where the Inputstream generated on this file is assuming the location of the file. In the other case, with classpath: i get an Exception stating that classpath: is not a valid protocol. I read the tutorial, the help and the faq on H2database and i already tortured google for an answer. I want to add the script to my deployable so that the application is runable with the least possible effort for the user. Ok so now i have everybody confused. Here is my question again: How do i get a relative path in INIT="RUNSCRIPT from ..." to work? Thanx in advance Desperately Mike -- 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.
