I found a very evil häck:
Statement insertStatement = conn.createStatement();
String path = getClass().getResource("/" + sqlFileName).getFile();
if(System.getProperty("os.name").contains("Windows")){
path = path.substring(1);
}
String insert = "RUNSCRIPT FROM '" + path + "';";
insertStatement.execute(insert);
or very easy:
RUNSCRIPT FROM 'src/test/resources/test.sql';
but the most elegant solution is to use
org.h2.tools.RunScript.execute - as Noel proposes in his post here.
Am Montag, 10. Februar 2014 11:29:36 UTC+1 schrieb Rémy Schumm:
>
> I try to do a veery easy JUnit-Tests whitch triggers a RUNSCRIPT FROM...
>
> *I find no way to load the SQL-file realtively. *
>
> The SQL-File is placed into src/test/resources
>
>
> Here is the code which makes the Problem:
> https://gist.github.com/rschumm/8913517
>
>
> Does somebody have an idea how to make H2 find this file? That'll be
> great...
>
>
>
>
>
--
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/groups/opt_out.