[英]Java application with embedded Derby database
I created a java swing application with apache derby database. 我用apache derby数据库创建了一个Java swing应用程序。 I want to know how can i do the following things.
我想知道我该怎么做以下事情。
The first time the application is double-clicked by a user, that finds a suitable location for the Derby database on the user's machine, creates the database and defines all the tables, views, etc and loads any initial data. 用户首次双击该应用程序时,将在用户计算机上找到适合Derby数据库的位置,创建该数据库并定义所有表,视图等并加载任何初始数据。 Then, on subsequent runs of the application, it will be able to re-open the database and continue using it.
然后,在应用程序的后续运行中,它将能够重新打开数据库并继续使用它。
user.home
property from System.getProperty
which will return you the user's home directory as the main path for the database. System.getProperty
的user.home
属性,该属性将返回用户的主目录作为数据库的主路径。 On Windows, I would recommend using {user.home}\\AppData\\Remote\\{You application name}
as a base path {user.home}\\AppData\\Remote\\{You application name}
作为基本路径 Following shall start derby database service on default port (1527) on localhost 以下应在localhost的默认端口(1527)上启动derby数据库服务
NetworkServerControl obj= new NetworkServerControl();
obj.start(null);
Use dburl with 'create=true', ie 将dburl与'create = true'一起使用,即
jdbc:derby://localhost:1527/macdb;create=true
Above shall make db dir (macdb), same name as service name on current dir. 上面将使db dir(macdb)与当前目录上的服务名相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.