I am making a small application and I am using the embedded derby database ,I want the application to be able to save the whole database onto a single file which can be stored on the hard drive and also import the database by opening this file in the future.Any clues or examples on how can I do it?
我正在制作一个小应用程序,我正在使用嵌入式德比数据库,我希望应用程序能够将整个数据库保存到单个文件中,该文件可以存储在硬盘驱动器上,并通过打开此文件导入数据库。 future.Any线索或例子我怎么能这样做?
2 个解决方案
#1
4
This might help you out!
这可能会帮到你!
1- Resource 1 with all detail
1-资源1包含所有细节
2- Resource 2 with Export Detail only
2-资源2仅限导出详细信息
3- Using Java to Export/Import Using Jdbc
3-使用Java导出/导入使用Jdbc
To export all the data from a table to a single export file, including the LOB data
将表中的所有数据导出到单个导出文件,包括LOB数据
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))
SYSCS_UTIL.SYSCS_EXPORT_TABLE(IN SCHEMANAME VARCHAR(128),IN TABLENAME VARCHAR(128),在文件名中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 the LOB data
将SELECT语句的结果导出到单个文件,包括LOB数据
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 VARCHAR(128))
SYSCS_UTIL.SYSCS_EXPORT_QUERY(IN SELECTSTATEMENT VARCHAR(32672),IN TABLENAME VARCHAR(128),在文件名中VARCHAR(32672),IN COLUMNDELIMITER CHAR(1),IN CHARACTERDELIMITER CHAR(1),IN CODESET VARCHAR(128))
Import and export procedures from JDBC
从JDBC导入和导出过程
You can run import and export procedures from a JDBC program.
您可以从JDBC程序运行导入和导出过程。
The following code fragment shows how you might call the SYSCS_UTIL.SYSCS_EXPORT_TABLE procedure from Java. In this example, the procedure exports the data in the staff table in the default schema to the staff.dat file. A percentage (%) character is used to specify the column delimiter.
以下代码片段显示了如何从Java调用SYSCS_UTIL.SYSCS_EXPORT_TABLE过程。在此示例中,该过程将默认架构中staff表中的数据导出到staff.dat文件。百分比(%)字符用于指定列分隔符。
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();
#2
1
Your question makes me wonder if you think you need to do this to persist your data. Just to be clear: You don't - your data is persisted on disk automatically. In fact all inserts and updates that have been committed are guaranteed to be persisted even if the jvm or machine should crash (as long as the disk is intact and the disk's write cache has been disabled).
您的问题让我想知道您是否认为需要这样做以保留您的数据。需要明确的是:您没有 - 您的数据会自动保留在磁盘上。事实上,即使jvm或机器崩溃(只要磁盘完好无损且磁盘的写缓存已被禁用),所有已提交的插入和更新都会保证保持不变。
D
#1
4
This might help you out!
这可能会帮到你!
1- Resource 1 with all detail
1-资源1包含所有细节
2- Resource 2 with Export Detail only
2-资源2仅限导出详细信息
3- Using Java to Export/Import Using Jdbc
3-使用Java导出/导入使用Jdbc
To export all the data from a table to a single export file, including the LOB data
将表中的所有数据导出到单个导出文件,包括LOB数据
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))
SYSCS_UTIL.SYSCS_EXPORT_TABLE(IN SCHEMANAME VARCHAR(128),IN TABLENAME VARCHAR(128),在文件名中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 the LOB data
将SELECT语句的结果导出到单个文件,包括LOB数据
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 VARCHAR(128))
SYSCS_UTIL.SYSCS_EXPORT_QUERY(IN SELECTSTATEMENT VARCHAR(32672),IN TABLENAME VARCHAR(128),在文件名中VARCHAR(32672),IN COLUMNDELIMITER CHAR(1),IN CHARACTERDELIMITER CHAR(1),IN CODESET VARCHAR(128))
Import and export procedures from JDBC
从JDBC导入和导出过程
You can run import and export procedures from a JDBC program.
您可以从JDBC程序运行导入和导出过程。
The following code fragment shows how you might call the SYSCS_UTIL.SYSCS_EXPORT_TABLE procedure from Java. In this example, the procedure exports the data in the staff table in the default schema to the staff.dat file. A percentage (%) character is used to specify the column delimiter.
以下代码片段显示了如何从Java调用SYSCS_UTIL.SYSCS_EXPORT_TABLE过程。在此示例中,该过程将默认架构中staff表中的数据导出到staff.dat文件。百分比(%)字符用于指定列分隔符。
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();
#2
1
Your question makes me wonder if you think you need to do this to persist your data. Just to be clear: You don't - your data is persisted on disk automatically. In fact all inserts and updates that have been committed are guaranteed to be persisted even if the jvm or machine should crash (as long as the disk is intact and the disk's write cache has been disabled).
您的问题让我想知道您是否认为需要这样做以保留您的数据。需要明确的是:您没有 - 您的数据会自动保留在磁盘上。事实上,即使jvm或机器崩溃(只要磁盘完好无损且磁盘的写缓存已被禁用),所有已提交的插入和更新都会保证保持不变。
D