Standalone DB with Hibernate - java

I have to develop a Spring MVC project. This give user the possibility to work online using normal web access. I also need to give user possibility to work offline.
So I want to develop a standalone java app that the users can install on theirs pc. They can exchange data with server using JSON with Jackson for example.
My question is about the client side. Supposing to handle data with an ORM like Hibernate, which standalone db are best suited for avoid to install DBMS (like mysql, mssql, ...)?
I want to avoid install many software on client.
I have developed a project like this, where the clients are Android tablet, the ORM tool is ormlite and the db sqlite. The db consist in a file.
Thank you for any response!!
Marco

I'd actually recommend H2 Database over Apache Derby. I've used both, and found that Derby can be difficult to configure and access in a non-embedded manner (which may not be an issue for you, but it was for me).
H2 was faster also.

Apache Derby works well locally, is embeddable, fast and small (2.5 MB).
If you are more comfortable working with "officially supported" products, you could go with JavaDB - it's Derby in disguise.

Related

The derby database

In the IT class room I constantly hear chat about the derby database not being built for netbeans. I write code in java and becuase I am learning to implement databases and I have the oppurtunity to be taught sql code. My question is, is the derby database not meant for netbeans and if not why why? So far it works fine for me. Our education system is a bit out of order so I like to be well informed about things.(You don't have to worry about making sense about the last statement).I use the database for recording details in shop and company scenarios so far. So answer could relate to this.
The Java DB(Derby) database is Oracle's supported distribution of Apache Derby. Java DB(Derby) is a fully transactional, secure, standards-based database server, written entirely in Java, and fully supports SQL, JDBC API, and Java EE technology. The Java DB database is packaged with the GlassFish application server, and is included in JDK 8(except Mac OS X) as well.
There is a whole official NetBeans IDE Tutorial about Working with the Java DB(Derby) Database. Whoever has suggested you those incorrect details,he might not have got to work with Derby Database OR might be a fan of Oracle/MySQL,etc. databases! But,I and all the commentators post suggest you to move frankly with Derby database as there is no such problem!
Also,I am leaving you the official tutorial's link---> Official NetBeans IDE Tutorial on Java DB(Derby) Database

Connecting to a Cache (InterSystems) Database using Java

I'm currently creating an android application and need to connect to a InterSystems cache (ODBC) database, this is the first time I have developed for android and have never connected to a database in java in the past, any help will be appreciated.
For Android development, I would highly recommend to use web services or Rest instead of ODBC. But there is a standard JDBC Java documentation (not sure if it will work in Android at all though):
http://docs.intersystems.com/cache20131/csp/docbook/DocBook.UI.Page.cls?KEY=ITECHREF_jdbc
You can also have a look at newer Zen Mobile framework designed specially for iOS/Android Cache development, ask for a copy in WRC
Do you really think it's a good idea to connect to the DB right from the user app? Accessing directly from user app to the DB is usually bad for you. I don't say "don't do it". Caché allows you to grant privileges to individual tables in SMP. (But you can't let the user to only access some records of a table.)
I know InterSystems Ensemble can communicate using SOAP, I am not sure about just Caché and REST, you would have to do a research of your own. However, I think it's a better idea than accessing the DB directly from the client. You could also cause problems with database's integrity by doing so.

Java based Standalone application

I am developing a standalone application for a client using Java Swing and jdbc with MySQL. I am using MySQL as the database.I want to know that how the client can install MySQL, is there a way by which the client can install MySQL in his machine,or can i distribute the MySQL setup.The client just needs the software running and do not want to go to any installation process.
What is the way around with that??
Use Java Web Start to launch the app.
The MySQL installer can be invoked from an installer-desc element in the launch file. Here is my demo. of the JNLP API ExtensionInstallerService.
You're likely to find H2, HSQLDB, Derby, or SQLite to be more suitable for your deployment. They're intended to be embedded in other applications.
This might not be the simplest solution, but it is a good idea to have an installer for your application, which would take care of MySQL installation. IzPack is a very reasonable installation tool, which can execute external applications (e.g. MySQL installer) as part of the installation process. This discussion might be of some interest.
However, as mentioned in other replies, the use of an embedded RDBMS such as H2, SQLite etc., is a better choice than MySQL for a standalone application.
Few portable database alternatives: Derby, SQLite.

Selecting a JDBC Driver

I'm trying to select a JDBC driver for an application I'm building and I've found lots of drivers, but I can't seem to narrow the selection down to one. The driver I select should have the following features:
Free for commercial use
Easy to install (eg. single jar file, no drivers to install)
Easy to use (well documented)
No database server required
Multi-user / Network support
What JDBC database drivers would you suggest?
So far I've considered TinySQL and SQLite.
The database is not very large think maybe 10k records.
The JDBC driver depends on the database you want to use. Some free databases include:
Derby (small, lightweight, comes with Java 1.6)
MySQL (bigger, lots of features)
PostgreSQL (bigger, lots of features)
I'm sure there are others.
When you install the database, the documentation will tell you where to get the JDBC driver.
Unless you have specific requirements, I would have suggested that you use MySQL, it is free and very popular. Also, it is very easy to use through JDBC. However, I then saw your comment:
I want to use a JDBC driver so if I
change databases the database will
have the same interface. Right now I
need a database that meets the above
requirements.
The problem is that, as far as I know, JDBC alone isn't that flexible. With JDBC you basically pass strings to and fro the application and the database engine. If you want something that allows you to change the database but doesn't impact the way that your application and database communicate, you should consider and ORM tool like Hibernate.
The OP asked for 'no database server'. That means that there are two options in common use: Derby and HSQLDB that integrate well into Java.

How to take a Java Web-application offline?

We develop Java Web-aps (Websphere, DB2) which display graphical and databased information. We would also like to offer the same application offline (distribution via CD/DVD) with online data-update. We have tried a number of alternatives in the past, but nothing has been really stable. What are the new best practices to take a Web ap plus data (in a small database) offline?
I don't know how well it works with the CD/DVD distribution front, but the first thing that comes to mind is Gears. On the .NET side of the fence there's Silverlight 2. Then there's the Mozilla Prism project, although I don't know how far advanced that is.
These are all designed for not just offline access, but mixed offline/online, talking to a server when it's available and working locally when necessary.
I'd suggest using Apache Derby as the database (also available as Sun's Java DB, and possibly still IBM Cloudscape (does that still have DB2 compatibility in place?)).
I'm sure there's plenty of Web servers/Servlet containers about. Apache Tomcat is the obvious one. An alternative approach would be to use an embedded native browser within a single Java process. That approach should be relatively hassle free for users and tech support, and you can just use WebStart to install and update.
If you're using EJBs and other nonsense, then there are similar freebies about. I understand Sun Glassfish is nice and fast starting.
You could create an image of your server as a VMware instance and distribute it with a copy of VMware player (licensing allowing of course). Personally I'd build it on top of a Linux distribution like CentOS5.
You can bundle a JRE along with JETTY server and use a different database e.g HSQLDB (that you can bundle inside the webapp itself).
If you are using an ORM tool to connect to database, you might not have to make many code changes for this.
A lot of Application server distribute their admin consoles like this.For e.g Weblogic admin console runs offline (it uses internal ldap server for its database)
Also as far as Google gears is concerned, they are also pretty much doing the same thing.
They have a server that is bundled along with SQLDB and they allow to synchronize the data between online offline app.
You can sync the data too (use webservices in the online app) and talk over https from the offline app to sync the data, if you need the sync feature.
Also you can check this link
http://developers.sun.com/learning/javaoneonline/2007/pdf/TS-69700.pdf

Categories