Skip to content
Advertisement

H2 org.h2.jdbc.JdbcSQLSyntaxErrorException occurs when executing a script file in a h2 database

I have used java -cp h2-1.4.199.jar org.h2.tools.RunScript -url jdbc:h2:mem:db1 -script infra_params.sql command to execute below sql script in a H2 database.

infra_params.sql file:-

But it gives following exception:-

Any help on how to fix this issue would be appreciated.

Advertisement

Answer

LOCK TABLES is a MySQL-specific command, it isn’t supported by H2.

You need to remove it from your file.

If you really need to use the same script in both MySQL and H2 and need this command in MySQL, you can try to wrap it into executable comment. MySQL, unlike other databases, executes code in /*! … */ comments.

/*! LOCK TABLES `infrastructure_parameter` WRITE; */

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement