views:

395

answers:

8

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

+3  A: 

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.

adatapost
we need to add empty data base or our existing database or both?sorry i dont have any idea how to do this?
pratap
I agree with the Nullsoft installer. Takes a few days getting use to. But very powerful.
Koekiebox
+1  A: 

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

Marius
A: 

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.

Pierre
+6  A: 

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.

Brian Agnew
A: 

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.

victor hugo
+1  A: 

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
Chintan
A: 

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.

James Anderson
could you please explain the last paragraph in details.
pratap
Its quite simple you build an access db with all the tables you need, populate it with any data your application absolutly requires ( things like currency codes , tax rates etc.). Access will store all this in a sinlge *.mdb file which you can then package with your application and use as a default database.
James Anderson
A: 

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.

NateS