Hi,
I'm not quite sure, but I think the problem is that ${project.basedir}
contains backslashes, which are escape characters within this part of the
database URL (after the semicolon), so they are removed.
What might work (not sure) if to use the classloader instead of an absolute
path, that is:
<jdbcUrl>jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:/create.sql'</jdbcUrl>
That should work, if the file "create.sql" is a resource within the
classpath. I'm not quite sure however if that's the case. See also the H2
documentation, "advanced" / "pluggable file system".
Regards,
Thomas
On Friday, November 29, 2013, Mikko Tommila wrote:
> I'm using querydsl-maven-plugin on Windows and there's apparently no
> feasible way to specify a Windows file path in the JDBC URL settings.
>
> What I have in the pom.xml is:
>
> <configuration>
> <jdbcDriver>org.h2.Driver</jdbcDriver>
> <jdbcUrl>jdbc:h2:mem:;INIT=RUNSCRIPT FROM
> '${project.basedir}/src/main/resources/create.sql'</jdbcUrl>
> <packageName>com.mycompany.model.querydsl</packageName>
>
> <targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
> </configuration>
>
> This works on Linux but not on Windows. The backslashes in the basedir get
> removed, as ConnectionInfo.readSettingsFromURL() calls
> StringUtils.arraySplit(), which removes the backslashes.
>
> (Escaping the backslashes would be excessively difficult in Maven,
> unfortunately.)
>
> I could change the configuration to use a file URI instead of a file path,
> like this:
>
> <jdbcUrl>jdbc:h2:mem:;INIT=RUNSCRIPT FROM
> '${project.baseUri}src/main/resources/create.sql'</jdbcUrl>
>
> However it does not work either, because first the file: prefix is removed
> from the URL in FilePathDisk.translateFileName(), and then
> FilePathDisk.newInputStream() does not recognize the resulting
> "/C:/something" as a Windows path, because it only expects the filename to
> start with e.g. "C:/" and not "/C:/".
> Possible fixes could be:
>
> - Do not remove the file: prefix for file URLs
> - Recognize file paths starting with "/C:" (or some other drive
> letter) as Windows paths
> - Use Linux, do not use Windows
>
> Using Cygwin doesn't help anything as Java anyway reports Windows file
> paths and not Cygwin file paths. A native Java isn't available for (64-bit)
> Cygwin.
>
> Mikko
>
> --
> 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] <javascript:_e({},
> 'cvml', 'h2-database%[email protected]');>.
> To post to this group, send email to
> [email protected]<javascript:_e({}, 'cvml',
> '[email protected]');>
> .
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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.