I am making a Java desktop application which involves lot of data, state, etc.
I must store all this data in a DB for querying purposes.
Now if I distribute my application I will have to distribute the DB packaged along with the
application itself.
Which is the best open source "Packagable" DB which I can use for this purpose.?
(assuming say my application is for commercial purpose)
I don't want the end-users of my application to install a DB like MySQL seperately
I want it to be part of my application .msi(or zipped) installer, at the sametime it should not be too large (>50MB) and it should not require the user to take any additional steps for installation.
There is no best, but suitable. Try sqlite, its relatively fast, simple db library. Free
I can't recommend a best database, but I like using the Derby DB (or Java DB which is Oracle's Derby distribution).
Related
I'm creating a java desktop application using swing which requires some database persistance for which I'm planning to use Hibernate. I'm pretty new to desktop application development so I wanted to know if and how the database can be created on the client computer when installed.
Is there a script to be run or maybe a hibernate configuration which initiates database creation?
A sample tutorial or example illustrating this will be ideal (although I was not able to find one).
Thanks in advance for any help provided.
Hibernate is not an database server itself, it is a object-relational mapping framework so you need a either embedded or stanalone database server. Java DB that comes with the JDK will be sufficent for desktop applications.
http://hamidseta.blogspot.in/2008/05/install-mysql-server-50-silently.html
In your package installer scripts perform the steps of silent MySql installation. In the BAT file put the code you find in the above link before triggering your Java application installer.
As per free licensing terms, one should not package MySql bundle for free, just check about the licensing if you bother.
I think it would be better if you can start with javaDB or SQLite.
They are perferred embedded database technologies for desktop java applications.
You can download the jar for sqlite-jdbc from here.
Take a look at few tutorials on JDBC
If you making swing applications, make sure you learn to use swing worker well. It will
be important to perform background processing.
Hibernate is Framework used as middle layer in project which interact between database and Business layer logic.
Hibernate features
J2EE integration
Object/Relational mapping
Automatic primary key generation
Object-oriented query language
So my suggestion is to go with MySQL because
Handles large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 60,000 tables and about 5,000,000,000 rows.
A very fast thread-based memory allocation system.
Very fast joins using an optimized one-sweep multi-join.
The server can provide error messages to clients in many languages.
This is only few features but you go to official site for more detail. And most important it's open source.
And the post help to install and configure on client system.
I have never used Derby but I've seen that it can be embeded in my java application. If I decide to make my application by derby is there a way to place my database files in my specified application directory so I expect it to be portable and when I copy the database files to another application which can use them they will be copied safely?(I think that it was impossible for mysql thus it has a global configuration)
By the way I'd like to know if Derby has a client/server access system or it can be used like SQLite. My database is so easy and I need no client/server structure. Do client/server structures reduce the performance when they are compared with SQLite structure?
Derby is an open source relational database implemented entirely in Java based on Java, Sql, JDBC standards.
when I copy the database files to another application which can use
them they will be copied safely?
Yes it is portable and can be copied safely
I'd like to know if Derby has a client/server access system or it can
be used like SQLite
Derby supports the more familiar client/server mode with the Derby Network Client JDBC driver and Derby Network Server. check this link
for a full tutorial on how to use Derby with eclipse I'd suggest you to read this tutorial written by IBM
Good Luck
I'm creating a simple CMS software which doesn't have much data to be stored. I'm currently using mysql as my data provider and have a java application in the presentation layer. This CMS will be a standalone which means datacollection and processing will be done in a single computer.
I created a installer to install in my clients computers. But I need to setup mysql then the database as well. And my clients doesn't have sufficient IT knowledge to setup the databases themselves. So for each client I have to attend and install mysql server.
What I need is a way to integrate data-provider to the application without using mysql or any other sql or nosql server. So my clients can install it themselves using simple guided steps in installation wizards.
You can use one of embedded db, like JavaDB (ex. Derby). Support of this database is added to JRE. So all your client need is installed JRE. And you get full relational database without any installation and other stuff setup.
You can try using hsqldb or sqlite db. These dbs can be bundled with the application in memory or can use a simple file as db. Hope it helps
I found a good example here
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/
thanks every one for help
I recently made an interesting application using Play Framework and MySQL Connector/MXJ to make a completely portable web server with database, independent of any currently installed software(including Java).
I'm still new to MXJ, and the desktop application realm (as opposed to straight-up webapps), so I'm wondering if there are other, better methods for storing/accessing large amounts of data than embedded MySQL. I would assume so, since it seems not many people use MXJ. It essentially just packs mysqld.exe in its various forms for multiple operating systems and platforms. It runs in its own thread, and stores its data in whatever directory you provide.
For an application that frequently analyzes and searches through data in large chunks(100MB to 5GB), what other (fast)options are there, or am I justified in my webapp-laziness of bringing along MySQL?
Independent of any currently installed software(including Java).
If you are looking for an embedded database for a desktop application, then you can go for SQLITE. However, there are pros/cons for using either MySQL or SQLite
SQLite:
Easier to setup
Great for temporary (testing databases)
Great for rapid development
Great for embedding in an application
Doesn't have user management
Doesn't have many performance features
Doesn't scale well.
MySQL:
Far more difficult/complex to set up
Better options for performance tuning
Fit for a production database
Can scale well if tuned properly
Can manage users, permissions, etc.
You can find more info on when to use SQLite here
UPDATE: I came across HSQLDB and here are its test results. HamsterDb is another option.
Do you really need a database if your app is single user and desktop based? Maybe it is faster to simply write large files to the local filesystem then loading then through the network tier. If your app is very complex you could use an embedded db just for storing your domain and configuration, but if its not maybe you can avoid using a db + sql + o/r-mapping and so on.
i am not clear about steps/configuration details about how i can embed mysql in a Java desktop application so that it(application) can be installed on any machine through a single executable file and doing so sets up database and also provides an exe to run the app.Till now i have built my app using netbeans and i have used mysql to set up database.plz guide me further.
MySQL isn't an embedded database - the only JAR related to it is the JDBC driver. It requires a installation process, which might be able to be scripted via Java, but the process will definitely function outside of the Java application you intend it to support. Meaning, you can turn off your Java application but the MySQL service/daemon will still be running.
Only the libmysqld is embeddable.
There are embedded databases - SQLite, Firebird - and embedded databases made in Java - HSQL, Derby/(can't remember what it was called before). I believe SQL Server Compact Edition is embeddable, while SQL Server Express/MSDE is not. I don't know if Oracle has an embeddable version....
I would strongly recommend H2. It is a very fast embedded database written in Java and I've found it easier to use than some of the others mentioned such as HSQL.
Edit:
On the H2 website, you can see a speed comparison of H2 vs Derby, HSQL, MySql, etc...
Here's information on how to backup the database.
While theoritcaly possable it would not be easy. The standard MySql distributions assume you want to set up a general purpose database server with separate from the client applications cominicating via odbc etc.
You may be better looking at the "pure java" options like HSQL or JavaDB which are designed to be embedded in a java application, and need little or no "setup".
Another possibility is Sqlite which only needs a single binary plus the sqljbbc jar file. This is again designed from scratch to be embedded inside an application and requires zero admin apart from allocating a file for the database.
Take a look at http://dev.mysql.com/doc/refman/5.0/en/connector-mxj.html. I do not remember the exact details but I was able to embed MySQL db in desktop application without user needing to install it separately.
The key class is com.mysql.management.MysqldResource.
Here is the example, http://dev.mysql.com/doc/refman/5.0/en/connector-mxj-configuration-java-object.html
The mysql-connector-mxj-gpl-db-files.jar file contains MySQL installation files for all the platforms. If you know which is your target platform, you can strip other platform versions from jar, to reduce download size for end user.
If you want an embedded database with java, then use one written in Java designed to be embedded. I know Apache Derby Can be embedded and apparently H2 too.
How big amount of data dó you need the database to handle?