简体   繁体   中英

How to transfer my MYSQL table to a derby database?

I am trying to use Derby with eclipse, do I have to have the Java EE eclipse? Also is there a way to import a MYSQL table into a derby database? Sorry if these questions are really basic, Im new to derby and I need it to work fast(project due today etc) Thanks

http://db.apache.org/derby/integrate/db_ddlutils.html

DdlUtils, an Apache DB subproject, provides utilities for creating and working with Database Definition (DDL) files and for exporting and importing data in XML format via Ant tasks or programmatically in Java.

Among other uses, DdlUtils makes it easier to migrate from one database vendor to another. This paper provides a simple example for using DdlUtils to migrate a database to Derby using the DdlUtils Ant tasks.

This example features Derby as both the source and target database because Derby is easily available and is what the author knows, but it can be used with any of the databases that DdlUtils supports. Usually there's an even easier way to migrate a Derby database from one machine to another: just copy the Derby database files. If the source and target machines use official Derby releases you don't need to export/import the schema and data, not even for machines with different architectures, because the files that make up a Derby database are platform-independent. However, if you want to upgrade a Derby database to or from an alpha version of Derby to an official release, you must export the schema and data because Derby doesn't support upgrading an alpha database. DdlUtils makes this migration easier.

You can import your CSV data into Derby with something like:

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE (
                             null, 
                             'Sampletable',
                             'Sampledata.csv', 
                             ';', 
                             null, 
                             null, 
                             0);

as explained in this blog post .

Here is the Derby docs for arguments.

No need to buy anything ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM