bmatthews68 / inmemdb-maven-plugin

A Maven 3 plug-in that can be used to launch an in-memory database for use in integration tests. Apache Derby and HSQLDB are both supported.
http://inmemdb-maven-plugin.btmatthews.com
Apache License 2.0
15 stars 7 forks source link

Inserting data on h2 database via script does not work. #21

Closed GuidoDechamps closed 9 years ago

GuidoDechamps commented 9 years ago

Inserting data via script on h2 db does not work.

I have the following maven plugin configuration where i try to clean the database, create the tables, insert some data. When Inserting the data using a sql script it does not work when the db is H2. It does work when the db is hsqldb. Using a dbunit datascriptb on a h2 database does work.

com.btmatthews.maven.plugins.inmemdb inmemdb-maven-plugin 1.4.3 11527 inmemdb h2 testDB ``` ${project.basedir}/src/test/resources/sql/dataSet.xml ``` ``` ,


</code>
bmatthews68 commented 9 years ago

Hi Guido,

Can you send me the output containing the error?

Thanks, Brian

On 26 November 2014 at 13:13, Guido Dechamps notifications@github.com wrote:

I have the following maven plugin configuration where i try to clean the database, create the tables, insert some data. When Inserting the data using a sql script it does not work when the db is H2. It does work when the db is hsqldb. Using a dbunit datascriptb on a h2 database does work.

com.btmatthews.maven.plugins.inmemdb inmemdb-maven-plugin 1.4.3

11527 inmemdb h2 testDB

                 <dataSet>
        <sourceFile>${project.basedir}/src/test/resources/sql/dataSet.xml</sourceFile>
    </dataSet>

    <!--<script>-->,
            <!--<sourceFile>${project.basedir}/src/test/resources/sql/test-data.sql</sourceFile>-->
                    <!--</script>-->
                </sources>
            </configuration>
        </plugin>

— Reply to this email directly or view it on GitHub https://github.com/bmatthews68/inmemdb-maven-plugin/issues/21.

GuidoDechamps commented 9 years ago

I'm afraid i have to stand corrected. The issue was due to connection strings.

Having a look in the code i saw that the url created was jdbc:h2:tcp://localhost/mem:testDB This does start an in memory database that is available from outside the process.

The connection defined in the datasource was incorrect as it started it's own db persisted to a file jdbc:h2:tcp://localhost/~/testDB starts a h2 db perisisted to the user home dir

Setting a user and password on the db in the inmemdb-maven-plugin quickly identified all the errors. So issue closed.

GuidoDechamps commented 9 years ago

And thanks for the plugin :)