2

I have to create a java application that can run entirely from a DVD. The application must connect with a database that will be also on the DVD. I was thinking to use an embedded database but i dont know much about them. Do i have to start the database server from my java application and if i do, how should i do it?

Thanks in advance. Nick Tsilivis

Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
nick.tsilivis
  • 55
  • 2
  • 9
  • Note that writing to a database backed by non-writable media is not possible. – John Dvorak Nov 16 '12 at 12:17
  • 1
    You should consider running it from a flash drive rather than a DVD – Tito Nov 16 '12 at 12:17
  • Java comes with built-in support for Apache Derby. See the [documentation](http://docs.oracle.com/javadb/). It is indeed possible to run in standalone mode without the need of starting a server. – Edwin Dalorzo Nov 16 '12 at 12:21

2 Answers2

1

You can use SQLite which is a very light weighted version of SQL. It stores its data in a single file. You even don't have to log in with an username and password. Just add this jar sqlite-jdbc to your projects build path. You cann access it by following:

Class.forName("org.sqlite.JDBC");
Connection connection = DriverManager.getConnection("jdbc:sqlite:your_database.db"); //"your_database.db" is the SQLite database file on your DVD.

/*manipulate your db by using PreparedStatement, ResultSet, ...

You must have installed SQLite on your system SQLite Download

arminb
  • 2,036
  • 3
  • 24
  • 43
  • arminb thank you very much... At the point of getConnectioncall do i have to specify the exact path of the database file instead of your_database.db ? – nick.tsilivis Nov 17 '12 at 10:43
  • you don't have to specify the full absolute path to your database file. It's an relative path. If you're developing in eclipse just put it into the root of your project folder (workspace/your_project/your_database.db). Then you can access it by `DriverManager.getConnection("jdbc:sqlite:your_database.db");`in your code. – arminb Nov 19 '12 at 13:31
0

That sounds like a job for SQLite. It runs completely in your own process, so there is no need to start an external database server.

Community
  • 1
  • 1
hmakholm left over Monica
  • 23,074
  • 3
  • 51
  • 73