简体   繁体   English

在文件系统中打开Derby / JDBC数据库

[英]Open Derby/JDBC database in file system

I have a database that is used in Java with Derby/JDBC. 我有一个在Java中使用Derby / JDBC的数据库。 In the file system, I can see the following entries: 在文件系统中,我可以看到以下条目:

  • log (folder) 日志(文件夹)
    • log.ctrl (file) log.ctrl(文件)
    • log142.dat (file) log142.dat(文件)
    • logmirror.ctrl (file) logmirror.ctrl(文件)
  • seg0 (folder) seg0(文件夹)
    • c... (60 files with 8-7000 kB) c ...(60个文件,8-7000 kB)
  • tmp (folder) tmp(文件夹)
  • db.lck (file) db.lck(文件)
  • service.properties (file) service.properties(文件)

Is there any chance to open this database? 有没有机会打开这个数据库? I would like to convert this database to SQLite so I need to see the structure at least. 我想将这个数据库转换为SQLite,所以我至少需要看到这个结构。

Thank you very much in advance! 非常感谢你提前!

You should install Derby if have not already. 如果还没有,你应该安装Derby。 Derby comes with a command line tool ij . Derby附带命令行工具ij Use this tool to dump the tables as sql queries or csv files. 使用此工具将表转储为sql查询或csv文件。 You can uses these to import to sqlite. 您可以使用这些导入到sqlite。

First choose the output format using 首先选择输出格式

And then use these SQLs on the command line of IJ to export to file. 然后在IJ的命令行上使用这些SQL导出到文件。

Find details about ij here after clicking this link...click Running IJ. 点击此链接后, 在此处查找有关ij的详细信息 ...单击Running IJ。

Some basic IJ tool example 一些基本的IJ工具示例

For exporting data out of Derby 用于从Derby导出数据

Snippet for running IJ 用于运行IJ的代码段

`Method When to Use Command Run ij as a standalone command. `方法何时使用命令运行ij作为独立命令。 Use this method if you are relatively new to the Java programming language and new to Derby. 如果您不熟悉Java编程语言并且是Derby的新手,请使用此方法。 Follow the steps in Setting the environment variables before you run the ij tool using this method. 在使用此方法运行ij工具之前,请按照设置环境变量中的步骤操作。 To run the ij script from the command line, use: ij You must add the DERBY_HOME/bin directory to your PATH environment variable before you can run the ij tool. 要从命令行运行ij脚本,请使用:ij必须先将DERBY_HOME / bin目录添加到PATH环境变量,然后才能运行ij工具。

The ij script sets the appropriate environment variables, including the CLASSPATH, and starts the ij tool.` ij脚本设置适当的环境变量,包括CLASSPATH,并启动ij工具

Example of tool CLI: 工具CLI示例:

ij> connect 'sample' as sample1; ij>连接'sample'作为sample1;

ij> connect 'newDB;create=true' as newDB; ij>将'newDB; create = true'连接为newDB;

ij(NEWDB)> show connections; ij(NEWDB)>显示连接;

SAMPLE1 - jdbc:derby:sample SAMPLE1 - jdbc:derby:sample

NEWDB* - jdbc:derby:newDB;create=true NEWDB * - jdbc:derby:newDB; create = true

  • = current connection =当前连接

ij(NEWDB)> IJ(NEWDB)>

I recommend looking at SQuirrel SQL as it can copy data from one database to another. 我建议查看SQuirrel SQL,因为它可以将数据从一个数据库复制到另一个数据库。 Look on the plugins page for the DBCopy plugin. 查看DBCopy插件的插件页面。 With SQuirreL you can also right-click on a table in the objects view and generate the CREATE TABLE statement for the structure, etc. Handy. 使用SQuirreL,您还可以右键单击对象视图中的表,并为结构生成CREATE TABLE语句等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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