Java application that can run entirely from a DVD

2019-07-09 09:37发布

问题:

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

回答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



回答2:

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.