You will have to massage the dump file a little in order to get it to
import correctly into H2. All of those statements with the /* and */
will have to be manually removed.
I found it easier to create the structure in H2 first, then either do a
mysqldump of just the data and import that file, or dump the mysql
database into a csv file and use the csvread function and import that
data that way.
On 03/21/2013 04:17 AM, Peter wrote:
> Hello,
>
> I want to use H2 in-memory database for database driven integration
> tests of a struts web application (MySQL). Therefore i mysqldump my
> productive DB to a file and then try to initialize the H2 Dadabase
> with the mysql-Dump:
>
> setUpH2Database(){
> Class.forName("org.h2.Driver")
> Connection connection = DriverManager.
> getConnection("jdbc:h2:mem:YokoTrunkTest;MODE=MYSQL;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE;INIT=CREATE
> SCHEMA IF NOT EXISTS YokoTrunkTest\\;RUNSCRIPT FROM '/tmp/out.sql'");
> }
>
> The Problem is that this proceeding always results in a
> org.h2.jdbc.JdbcSQLException:
>
> CREATE DATABASE[*] ""YOKOTRUNKTEST"" "; expected "OR, FORCE, VIEW,
> ALIAS, SEQUENCE, USER, TRIGGER, ROLE, SCHEMA, CONSTANT, DOMAIN, TYPE,
> DATATYPE, AGGREGATE, LINKED, MEMORY, CACHED, LOCAL, GLOBAL, TEMP,
> TEMPORARY, TABLE, PRIMARY, UNIQUE, HASH, INDEX"; SQL statement:
>
>
> CREATE DATABASE /*!32312 IF NOT EXISTS*/ `YokoTrunkTest` /*!40100
> DEFAULT CHARACTER SET latin1 */ [42001-171]
> at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
> at org.h2.message.DbException.get(DbException.java:169)
> at org.h2.message.DbException.getSyntaxError(DbException.java:194)
> at org.h2.command.Parser.getSyntaxError(Parser.java:490)
> at org.h2.command.Parser.parseCreate(Parser.java:3844)
> at org.h2.command.Parser.parsePrepared(Parser.java:323)
> at org.h2.command.Parser.parse(Parser.java:278)
> at org.h2.command.Parser.parse(Parser.java:254)
> at org.h2.command.Parser.prepare(Parser.java:201)
> at org.h2.engine.Session.prepare(Session.java:390)
> at org.h2.engine.Session.prepare(Session.java:377)
> at org.h2.command.dml.RunScriptCommand.execute(RunScriptCommand.java:73)
> at org.h2.command.dml.RunScriptCommand.update(RunScriptCommand.java:56)
> at org.h2.command.CommandContainer.update(CommandContainer.java:75)
> ....
>
> Is there any advice from you to correctly import my MySQL Database,
> what are I'm doing wrong??? I googled a lot for a solution, but can't
> find an answer. (I use com.h2database in
> version1.3.171). I would be grateful if you could help me.
>
> Best regards
> peter
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
h2-database...@googlegroups.com.
> To post to this group, send email to
h2-da...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/h2-database?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Jeff K. Steinkamp (N7YG)
Tucson, AZ
Scud Missile Coordinates
N32.229 W110.875