Kamalam
Kamalam

Reputation: 1254

Script file in h2 database

I am trying to embed h2 database to my spring appplication by setting the following in applicationcontext.xml

<jdbc:embedded-database id="embeddedDataSource" type="H2">

<jdbc:script location="classpath:data.sql"/>

</jdbc:embedded-database>

When am executing it it shows the syntax error in data.sql file.But this file is a backup file from the working mysql database.Does the h2 support mysql backup script files.Can any one give me an example for the h2 script file.

The error it shows is

Syntax error in sql statement "create database[*] ""test"" ";expected "OR,FORCE,VIEW,ALIAS,SEQUENCE,USER,TRIGGER,ROLE,SCHEMA,CONSTANT"; sql statement:

My data.sql contains

create database 'test';

Upvotes: 0

Views: 2519

Answers (1)

Thomas Mueller
Thomas Mueller

Reputation: 50087

H2 is not 100% compatible with MySQL in the same way that other databases like Oracle, MS SQL Server, PostgreSQL and so on are also not 100% compatible with MySQL. Only MySQL is 100% compatible with MySQL. If you want to run SQL statements that were written for MySQL, then you need to make sure they don't contain any syntax that is not supported by H2.

it shows the syntax error

Could you post it?

Can any one give me an example for the h2 script file.

The supported syntax is documented on the H2 web site.

Upvotes: 1

Related Questions