Export Derby database as a single file?

I am making a small application, and I use the derby built-in database, I want the application to be able to save the entire database into a single file that can be saved on the hard drive, as well as import the database by opening this file in the future. Any tips or examples on how I can do this?

+4
source share
2 answers

It can help you!

1- Resource 1 with all the details

2- Resource 2 with export information only

3- Using Java to export / import Using Jdbc

To export all data from a table to a single export file, including LOB data

SYSCS_UTIL. SYSCS_EXPORT_TABLE (IN SCHEMANAME VARCHAR (128), IN TABLENAME VARCHAR (128), IN FILENAME VARCHAR (32672), IN COLUMNDELIMITER CHAR (1), IN CHARACTERDELIMITER CHAR (1), IN CODESET VARCHAR (128)

To export the result of a SELECT statement to a single file, including LOB data

SYSCS_UTIL. SYSCS_EXPORT_QUERY (IN SELECTSTATEMENT VARCHAR (32672), IN TABLENAME VARCHAR (128), IN FILENAME VARCHAR (32672), IN COLUMNDELIMITER CHAR (1), IN CHARACTERDELIMITER CHAR (1), IN CODESET 128)

Import and export procedures from JDBC

You can run import and export procedures from the JDBC program.

The following code snippet shows how you can call the SYSCS_UTIL.SYSCS_EXPORT_TABLE procedure from Java. In this example, the procedure exports data to the employee table in the default schema in the staff.dat file. Use the percent symbol (%) to specify a column separator.

PreparedStatement ps=conn.prepareStatement( "CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE (?,?,?,?,?,?)"); ps.setString(1,null); ps.setString(2,"STAFF"); ps.setString(3,"staff.dat"); ps.setString(4,"%"); ps.setString(5,null); ps.setString(6,null); ps.execute(); 
+4
source

Your question makes me wonder if you think you need to do this to save your data. Just to be clear: you won’t do this - your data is automatically saved to disk. In fact, all insertions and updates that were committed are guaranteed, even if the jvm or the machine should be damaged (until the disk is damaged and the write cache on the disk is disabled).

D

+1
source

Source: https://habr.com/ru/post/1501241/


All Articles