无法解析H2数据库URL

时间:2017-09-11 13:00:33

标签: java maven jpa eclipselink h2

尝试为maven项目创建一个embeded(也在内存中试过)数据库。 在我的persistence.xml中,我添加了以下url:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="org.xxxxxxxxx.validation.pu" transaction-type="RESOURCE_LOCAL">
        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/> 
            <property name="javax.persistence.jdbc.url" value="jdbc:h2:~/tmp/phenocapture_validation;INIT=runscript from 'classpath:sql/create.sql'\;runscript from 'classpath:sql/data.sql'"/>
            <property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
        </properties>
    </persistence-unit>
</persistence>

运行项目我收到以下错误。

Internal Exception: java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.core.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.

如果我只使用

,则网址有效
<property name="javax.persistence.jdbc.url" value="jdbc:h2:~/tmp/phenocapture_validation"/>

0 个答案:

没有答案