Embedded H2 Database Connection Error - wrong username and password
<p>I'm struggling with Hibernate, JavaEE Persistence and an embedded H2-Database.</p>

<p>I've got the following section in my persistence.xml:</p>

<pre><code>&lt;persistence-unit name="iot_pu"&gt;

    &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
    &lt;properties&gt;

        &lt;property name="hibernate.connection.driver_class" value="org.h2.Driver"/&gt;
        &lt;property name="hibernate.connection.url" value="jdbc:h2:/tmp/databases/iot;AUTO_SERVER=TRUE;MVCC=true"/&gt;
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/&gt;
        &lt;property name="hibernate.hbm2ddl.auto" value="create"/&gt;
        &lt;property name="hibernate.show_sql" value="true"/&gt;

    &lt;/properties&gt;

&lt;/persistence-unit&gt;
</code></pre>

<p>I get the following stack trace: </p>

<pre><code>    javax.persistence.PersistenceException: Unable to build entity manager factory

        at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:66)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at iot.utils.AbstractTestSuite.setUpClass(AbstractTestSuite.java:22)
        at iot.utils.AbstractTestSuite.getEmf(AbstractTestSuite.java:37)
        at iot.utils.AbstractTest.init
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
Caused by: org.h2.jdbc.JdbcSQLException: Falscher Benutzer Name oder Passwort
Wrong user name or password [28000-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.message.DbException.get(DbException.java:144)
    at org.h2.engine.Engine.validateUserAndPassword(Engine.java:333)
    at org.h2.engine.Engine.createSessionAndValidate(Engine.java:161)
    at org.h2.engine.Engine.createSession(Engine.java:136)
    at org.h2.engine.Engine.createSession(Engine.java:28)
    at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:349)
    at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:107)
    at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:91)
    at org.h2.Driver.connect
</code></pre>

<p>If I test the connection with IntelliJ it says that the connection works without problems - no username or password.
<a href="https://i.stack.imgur.com/b57FO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b57FO.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/hC8dd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hC8dd.png" alt="enter image description here"></a></p>

<p>The line that causes the problem (AbstractTestSuite.java:22) says</p>

<pre><code>Persistence.createEntityManagerFactory("iot_pu");
</code></pre>

<p>Can it be the case, that I've forgot something to import via Maven?</p>

<pre><code>.........
        &lt;dependency&gt;
            &lt;groupId&gt;com.h2database&lt;/groupId&gt;
            &lt;artifactId&gt;h2&lt;/artifactId&gt;
            &lt;version&gt;1.4.191&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
            &lt;version&gt;5.1.0.Final&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
            &lt;version&gt;5.1.0.Final&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
            &lt;version&gt;5.2.4.Final&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
            &lt;version&gt;1.0.1.Final&lt;/version&gt;
        &lt;/dependency&gt;
.........
</code></pre>