java - 我应该在哪里/什么时候创建一个表作为我的程序的基础?

标签 java swing sqlite deployment

我正在开发一个桌面 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/

相关文章:

java - 如何使用调试 shell 创建新变量

java - Jdbc - 无法连接到本地主机上的 MySQL 数据库

java - 为什么在使用图形时无法查看添加到 JPanel 的 JLabel?

java - 商业或开源 Java Swing 规则/谓词编辑器小部件?

java - 如何从 SOAP Web 服务获取图像

java - 需要专门获取 java-1.8.0-openjdk-amd64 并安装?

android - ListFragment 和上下文

android - 在 Android 平板电脑内存中保存 SQLite 数据库(API 23)

java - 如何在按下单独的 JButton 时停止使用 DefaultCellEditor 进行编辑

ruby - 使用多个参数插入会给出 SQLite3::RangeException