This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In the past, I've always used MS Access as a database because I found the connection easy to set up and it is the only database software we have in school. Now I have read that it is not 'good practice' to use MS Access as a DB source at all. Now I want to move over to an 'acceptable' database type. I have identified MySQL as probably the best choice and I have used it successfully with the MySQL server running. The problem is: Using Access allowed me to bundle my .mdb file with the application and the jar with the database driver and it would work on any machine on which my app is installed. MySQL seems to need the MySQL server running to access the database. This is a problem because an end user would not want to worry about setting up a database server before using any off-the-shelf software. How can I set MySQL up so that I can bundle the .sql file in my distribution and have java access it transparently without the user having to set up the server?
If I am on the wrong track here, please direct me as to what other type of database is the best to use for desktop applications so that the database connection can 'just work' on every computer my software gets installed on? Which database do Java developers generally use when creating 'out of the box' applications?
A database is probably not the best choice for a single user desktop application. I would just use the file system. Databases (Access aside) are intended to run on servers handling multiple requests from different users. If your system doesn't need this then don't use one.
If you feel you need a database and you want it running on the user's machine you probably would be best looking at a Java-based one you could completely control from your application, e.g. DerbyDB or HSQLDB.
As Paul mentioned, Derby and HSQLDB might be what you need. They are in a class of database referred to as 'embedded databases'. Basically, they start inside your application and are only available as long as your application is up. I'm not a huge fan of them, though, as I find the desire to centralize my data (such as a web-based application) paramount to running lots of disconnected copies of the database. Keep in mind, if you want to update the user's database you need to perform updates on every instance that it is installed on.