I need to find a suitable database for my application, that satisfy following criteria,
Zero intallation
Zero configuration
Portable (client wants database file to be able to shift from one machine to another manually.)
Please suggest me a suitable database for the above criteria.
For java I will go with Apache Derby (aka Java DB).
I recommend JavaDB, you can use it as an in process database and it has good performance. I have used it in several projects, mainly in Java Swing desktop applications.
I would recommand h2
Sounds like you should use SQLite for that.
Have a look at Java and SQLite for how to interact with the SQLite databae from Java.
for me mongodb also meets these criteria (unless you really need sql database)
Related
Iam developing a client/server app in java.
I need to store ids , passwords etc of all the users for login,document sharing and chat purposes.
I dont want to install any DBMS because i need only 1 or 2 tables with around a thousand entries.
Is there any way to do this??
Why not use the JavaDb which comes with the JDK as standard ? You can run it in-JVM and persist to the file-system. It's a SQL database so if you're familiar witha RDBMS it should be straightforward to integrate.
You can write the data to a local file on the server, and read it from there, but its hardly efficient.
Check out HSQLDB or H2 database. Both will fit your needs
Both have a rich set of SQL features, can run embedded or standalone and have a small memory footprint. Personally I prefer HSQLDB over H2 but not for a specific reason.
i'm planning to start the development of a java desktop application with a database embedded. It will be an application without internet connection and just for that, to insert, update and delete data on the database. It will be a lot of data.
So, i would like to have your opinions, what libraries should i use to incorporate the database in the application to have good performances in the end? Should i use jdbc derby that's already incorporated with neatbeans?
Thanks in advance!
I been using Derby in production for years and it works well. The H2 database also looks good, it's supposed to offer better performance than Derby but I haven't used it in production. Both of these, along with HSQLDB are good choices as they are pure java, all you need to do is bundle the required jar files with your application. Sqlite and Berkely are fine products but not written in Java so I imagine these would be a little more difficult to work with.
You don't need any particular libraries. Each of the above databases should provide a JDBC driver which is the standard way of doing things. You can certainly use an ORM such as Hibernate as mentioned above. This makes some things simpler but if you're just starting out, it might be better to avoid this at first.
Some popular options are:
HSQLDB
BerkleyDB
Sqlite
Derby
Its impossible to say if they will be "fast enough", since its all relative. What is fast enough? How powerful is the host machine? How big is your dataset? Etc etc.
However, I can say I have seen really good performance from HSQLDB, with fairly large dataset (100K records +) on fairly moderate desktop machines. Sqlite I only explored for android, but its pretty impressive on this platform (considering the hardware it is running on).
I think you should do a little proof of concept, and test them out with some simulated data.
If Derby is available, I would use Derby. HSQLDB is another good option. For libraries, I would look at some library for database access. Spring comes to mind. If you have control of the database, I would look at an ORM mapping framework such as Hibernate.
Suppose I created a standalone application in java and distributed it through my website.
What I need to know is what is the ideal Database solution I can use so that all the users can use the application without installing anything extra.
For example, if I use SQL server or MySql database, the downloader will need those installed so that I can dump my database on it. Another solution I see is to use Database file like Microsoft Access .mdb file. But that too will need Microsoft Office installed on the client. XML files are platform independent but anyone can open and change them.
What is the solution used by most of the applications?
H2 is a very potent candidate for your need. We use it as a default RDBMS in all our demo applications and also for db-driven unit testing.
You could use an embedded database. There are hundreds for Java some which use SQL and many which don't. Any database you use, you may want the users to be able to maintain, so users editing the data may be a good thing.
You could consider Derby as it ships with Java.
I would use plain flat files which are CSV formatted unless you have a more specific requirement. e.g. you can load and edit them in excel/spreadsheet editor/text editor.
H2 is the successor of HSQLDB (same developer). It is not only one of the finest embedded DBs for JAVA, it is also free, even for commercial use. It's great with hibernate and comes with with a powerful web-interface (you can start it by running the h2 jar file). Additionally there is the possibility to encrypt you database (AES). We use that feature for getting some security aspects right with some of our projects.
check javadb. it is easy and can be redistributed
Firebird can do this : there is an embedded version.
There is some good java drivers
Using MDB files on Windows doesn't require any additional installation requirements such as Microsoft Office. DAO and ADO have come with the Windows OS since Windows 2000.
I have a Java SE application, and it uses a database. I am currently using XML files to store data, but I´m afraid it causes some errors in later use.
So it would be good to use a Postgree/MySQL like DB. A real database. but the problem is, it is a commercial application, it runs under windows, and should be 2 clicks to install. I really don't like the idea of installing a database together with my application, and then running scripts to build the tables.
Is there a database that I can use as a Java API? Or should I just continue to use XML? (I'm synchronizing every access to my XML files). Whats the best choice?
One of following embedded databases:
HSQLDB
H2
Derby
They are lightweight, take up very little space and can be embedded without problems in your application.
Since they are written in Java, and each one is a simple jar file, your deployment headaches will be kept to a minimum.
You've mentioned MySQL and PostgreSQL. Although I haven't tried it, H2 features several compatibility modes for various popular databases, including ones you've mentioned.
H2 Database
It can be embedded in your application with no clicks to install and it supports JDBC and most ORMs.
It is definitely worth to look for a simple SQLite database as the storage. It is just a single file on your file system. No need to set up a server. Check out the following thread for an introduction: Java and SQLite Another database you could check out is HSQLDB (link inside another answer inside this thread). That one is a relational database engine written in Java also based on a single file.
Based on my previous naive experience of storing data into XML, I wrote a entire forum system on XML and it's based on RSS parser and writer. The XML files became very big and thus causing frequent request time outs on the application.
You can instead use something like SQLite, where data is stored in a file but more managed and allows declarative statements like SELECT * FROM table.
Is there a "best" or more popular database for standalone Java app?
I'm currently writing by hand, but I would like to know what is commonly done, if there is something that is commonly done.
update: talking about small app (may grow, but its small for now)
I would suggest using something like SQLite with SQLiteJDBC.
It also sounds like HyperSQL and Derby (which ships with certain Java versions) are popular choices.
Java 6 ships with Derby (renamed JavaDB). It can be used in memory or server mode.
HyperSQL (HSQLDB) is also popular.
For development purposes, I often use the Hypersonic SQL Database (HSQLDB). It's fast and lightweight, and good enough to get started.
For a bigger application, I'd go for Derby, which supports more options.
The main competitors - HyperSQL (HSQLDB), JavaDB (Derby) and SQLite (not java-based) were mentioned.
There are a few other options:
db4o - object database
FirebirdSQL - not java-based.
Jackrabit - a content repository (not RDBMS) supporting embedded mode.
HSQLDB is a well-established option.
JavaDB comes with the development kit
apart all those mentioned here, one can also go for H2 database which is light and can be used in-memory or in server mode.
For a SQL option, you could try MySQL, SQL Server, PostgreSQL, or Oracle. Those seem to be the most popular among Java developers.
If you want something NoSQL, MongoDB is the most popular choice with Java developers based on StackOverflow data from 2022.
You can find more information on the metrics used to make that determination in this article.