Migrating from H2 to mySQL

432 views
Skip to first unread message

Tariq Mehmood

unread,
Aug 15, 2012, 9:33:36 AM8/15/12
to h2-da...@googlegroups.com
Hi all,

I recently did a data transfer from H2 to mySql.
  1. I copied all the tables from H2 using a bash script
  2. Converted them into .csc files(each table has a .csv file)
  3. Ran mysqlimport command to dump these .csv files into MySQL database(data transfer to MySQL was successful, it is skipping some records in some of the tables, which i believe because of relationships)
  4. Gerrit is starting OK
  5. First user was created in MySQL table and given administrative rights.
I cannot see all the repos in Gerrit.
Error log is as follows:Thanks for the reply,
the error log looks like this in my case:

[2012-08-15 11:46:33,637] WARN  / : Error in allQueryNext
java.lang.IllegalStateException: Missing project All-Projects
    at com.google.gerrit.server.project.ProjectCacheImpl.getAllProjects(ProjectCacheImpl.java:90)
    at com.google.gerrit.server.account.CapabilityControl.<init>(CapabilityControl.java:55)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.google.inject.internal.DefaultConstructionProxyFactory$2.newInstance(DefaultConstructionProxyFactory.java:85)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
    at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:632)
    at $Proxy35.create(Unknown Source)

Any thoughts/pointer are welcome and Thanks in advance for your help.

Althought iam getting Application error in the browser but it is authenticating the user which was created when i hit continue.

Tariq

Robin

unread,
Aug 16, 2012, 12:23:23 PM8/16/12
to h2-da...@googlegroups.com
Hi,

probably you are inserting your Data in a wrong order? Like you want to create data with a foreign key, but the linked data doesn't exist?

So you should start with all Tables, that don't have any dependencies. If this is not possible for you, I think there is a so called batch mode or something (Do a research if you need it), with this mode you can insert your data and the dependencies will be checked after the whole batch is finished.

With best Regards 

Tariq Mehmood

unread,
Aug 16, 2012, 12:34:12 PM8/16/12
to h2-da...@googlegroups.com
Hi, Robin;

Thanks for the reply, i finally got rid of this error by reinitializing the gerrit server.
I donot see this error.
Now i am trying to verify the data i imported from H2.
Is there any easy way to verify that all the data was inserted correctly.

BR Tariq

and thanks again for looking into it.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/mtwTHdLmshkJ.

To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

Robin

unread,
Aug 16, 2012, 12:42:12 PM8/16/12
to h2-da...@googlegroups.com
Hi Tariq,

from my point of view, if everything works fine now, you shouldn't care about the error any more ;).

What I was trying to point out:
If you are migrating your data, it is important to insert at first the tables without any foreign keys. Then while(tables  left){ insert all tables that have only already created foreign tables). And if this algorithm ends up in an endless loop, you should try a batch insert mode (probably batch insert will be allways better?).

Greets Robin

Tariq Mehmood

unread,
Aug 16, 2012, 12:45:22 PM8/16/12
to h2-da...@googlegroups.com
Thanks,
Way i did it was that i created .csv files of each table from H2 and inserted them into to mySQL.
What do u think is this approach fine.
Or will i loose the relationships this way.

Seems you option of batch mode is better but have to research on this one know.

To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/NP5KEZdNaOMJ.

Robin Boldt

unread,
Aug 16, 2012, 12:51:59 PM8/16/12
to h2-da...@googlegroups.com
Hi,

if the insertion worked without any warnings or errors, the migration should have been successful ;)

2012/8/16 Tariq Mehmood <tari...@gmail.com>

Tariq Mehmood

unread,
Aug 16, 2012, 1:00:05 PM8/16/12
to h2-da...@googlegroups.com
Hi, 

Yep there were no errors or warnings just few records skipped.

Still need to figure out why its skipping those records..................

I think that is because of mySQL handles relationships differently than H2.
Reply all
Reply to author
Forward
0 new messages