pratap
pratap

Reputation: 131

database in desktop application using swing

I am making a desktop application in java and using MSAccess in data base. I want that if i run the setup of the application the database should be created on client machine because there can be different client using the application and how can i create the setup? is there any tools available for this free of cost? please explain me in detail.. thanks

Upvotes: 2

Views: 2355

Answers (8)

NateS
NateS

Reputation: 5876

I recommend the H2 database because it is simple, fast, pure Java, and small. See this page for how H2 compares to other Java databases, including those mentioned here in other answers. It has many features Derby/JavaDB and HSQLDB do not.

Upvotes: 0

James Anderson
James Anderson

Reputation: 27478

I would second the posters who recommend JavaDB.

It is absurdly easy to adminster from inside your application. Whats more because everything is native Java you dont get the char->unicode little-endian->big-endien and all the other conversion malarky you normally get when reading SQL into java.

The one tip is that with JavaDB is prepare your SQL statements. Prepared statements get cached and the resulting access program (similar to an access plan but actually a jvm program) is reused, the programs for "executed' statements are not cached.

If you are really set on MSAccess then I would suggest you package an "default.mdb" file with all your required tables defined and your classifcation tables populated. If the user's table does not exist then simply copy over the default .mdb file and open that.

Upvotes: 0

Brian Agnew
Brian Agnew

Reputation: 272237

Java 6 (enhanced for desktop application work) comes with a built-in database called JavaDb (formerly IBM's Derby). That will do what you want.

Here's a set of guides and tutorials on how to use it.

I would suggest that when your application first starts, it checks for the presence of the created database, and if it doesn't exist, it builds the database (via the appropriate SQL). I've used this approach before and it works quite well.

Upvotes: 8

Chintan
Chintan

Reputation: 471

When you say

access in database

do you mean Microsoft Access or access the data in a database.

I would advise against MS Access if that is the case. If not, you could either use the JavaDB or HSQLDB and the use SQL scripts to create the database. As a summary

  1. Package the application in one of the installers (InnoSetup or NSIS are good ones)
  2. When installing, extract all the files in proper folders
  3. Execute the SQL scripts before first running the application to ensure the database is setup, you can do other housekeeping tasks along with this step (refer to installer documentation for after-install steps)
  4. Your application is good to go

Upvotes: 1

victor hugo
victor hugo

Reputation: 35838

My option is HSQLDB since it's fast, reliable and easy to use.

In the documentation it's explained how to use the standalone database mode, this is primarily used for unit testing but it fits your case too. The good thing with this is that you just connect to the file based database without any special set up and if the files doesn't exist, they're created.

Upvotes: 0

Pierre
Pierre

Reputation: 35236

In the last distribution of NetBeans I used, there was a wizard to create such application. The application used the Java Persistence API to store the Data.

Upvotes: 0

Marius
Marius

Reputation: 58911

Have a look at SQLite, which is used by Mozilla (Firefox stores all bookmarks and history in a database) and several other major applications.

Upvotes: 1

KV Prajapati
KV Prajapati

Reputation: 94635

I prefer nullsoft. Take a look at Open Source Installers Generators in Java

@pratap: database should be created on client machine..

Add an empty access database to your setup.

Upvotes: 5

Related Questions