0

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'; 

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

whats the syntax for creating a new database named test in h2.is that the same like create database 'test';
If you read the H2 documentation, you will find there is no create database statement and databases are automatically created if they don't exist.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.