【问题标题】:Is it possible to access an SQLite database or (Sql browser for SqLite) from Java?是否可以从 Java 访问 SQLite 数据库或(用于 Sqlite 的 Sql 浏览器)?
【发布时间】:2016-11-04 12:17:53
【问题描述】:

我想工作非常便携,所以我没有在我的计算机上安装一个 2.7Gb 大小的 Sql Server 怪物。我想找到一个更简单的解决方案。例如,我有一个 Java 表单应用程序,它必须访问数据库(可能是服务器),我认为使用便携式数据库(Access 或 SqlLite)对我来说更容易。

它可以是安装程序解决方案,但不是很大,例如 1Gb 或更大。最初想使用文本文件或 Excel 来保存数据,但这种方式也很难,因为我无法轻松模拟行和表之间的约束和关系。

【问题讨论】:

    标签: java database sqlite txtextcontrol


    【解决方案1】:

    当然可以从 Java 访问 SQLite 数据库!如您所见here

    SQLite 中的数据库是单个磁盘文件¹。

    所以你只需要使用驱动程序来读/写这个数据库(文件)。

    Java 中的代码如下所示(取自here):

    How to Specify Database Files
    
    Here is an example to select a file C:\work\mydatabase.db (in Windows)
    
    Connection connection = DriverManager.getConnection("jdbc:sqlite:C:/work/mydatabase.db");
    
    
    A UNIX (Linux, Mac OS X, etc) file /home/leo/work/mydatabase.db
    
    Connection connection = DriverManager.getConnection("jdbc:sqlite:/home/leo/work/mydatabase.db");
    

    【讨论】:

      猜你喜欢
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      • 2016-12-10
      相关资源
      最近更新 更多