我正在开发一个桌面 java 程序,它利用 SQLite 数据库来恢复一些数据。我现在如何创建数据库和创建我的表:
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:mokvoc.db");
stmt = c.createStatement();
String sql = "CREATE TABLE COMPANY " + ...
问题
问题是我想在程序的整个生命周期内只执行此语句一次,特别是在程序运行的第一次 或在安装步骤期间。请告诉我如何执行此操作,是否需要添加新的 JFrame 或我现在不需要那样做?
最佳答案
对于部署 Java 桌面应用程序,最好的选择通常是安装应用程序。使用 Java Web Start . JWS 适用于 Windows、OS X 和 *nix。
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or locale, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
最后一个非常适合部署 DB API 本身。它可能用于许多不同的应用程序。
填充数据库最好作为上面 ..
的一部分完成,如扩展安装程序服务所示。这在安装时运行一次,在卸载时再次运行。
The
ExtensionInstallerService
is used by an extension installer to communicate with the JNLP Client. It provides the following type of functionality:
- Access to prefered installation location, and other information about the JNLP Client
- Manipulation of the JNLP Client's download screen
- Methods for updating the JNLP Client with the installed code
关于java - 我应该在哪里/什么时候创建一个表作为我的程序的基础?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089481/