0

I want to work very portable, so I don't install a monster of Sql Server which has 2.7Gb size on my computer. I want to find an easier solution. I have for example a form application in Java which must to access a database (maybe a server), I thought it's easier for me to work with a portable database (Access or SqlLite).

It can be an installer solution but not very big such as 1Gb size or more. Initially thought to use a text file or Excel for keep the data but this way is hard too because I can't easily simulate the constraints and relationships between lines and tables.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

1

Of course it is possible to access an SQLite database from Java! As you can read here:

A database in SQLite is a single disk file¹.

So you just need to use the driver to read/write from/to this database (file).

The code in Java would look like the following (taken from 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");
Niklas P
  • 3,427
  • 2
  • 15
  • 19