Does embedded Derby database go in Java jar? - java

I am working on project in java where I need to have both app as well as Database to be on USB .
I am thinking of either:
1) Installing MySQL on USB. But then I don't know how I would connect to my database that way. I also don't know how I would transfer the project from my development environment to client environment.
OR
2) Using embedded database like derby. I would package my app in jar and give it to the client. He could then keep it on USB and run it from their. In this case where would the database be stored? Will it be stored in the jar file? And if so how do I update my database in these scenario? Can I use ij tool from derby?
I am relatively new to derby.

For a great introduction to Derby and its features, follow this series of tutorials: http://db.apache.org/derby/docs/10.9/getstart/cgstutorialintro.html

Related

How to make a server for a Java and MySQL application

I created a Java application that accesses a MySQL database (made using MySQL Workbench). I want to create an installer for my application so that other users can use it on other computers, but I can't figure out how to do so.
I tried using Launch4j and Inno Setup Compiler, but when I tried to install the application on another computer it didn't access my database.
After a bit of research, I found out that I (maybe?) have to use a server for my database, but I couldn't figure out what and how to do that.
My questions are:
Do I have to use a server to make my application installable on other computers?
What is the easiest server to use for this task?
PS: I'm very new at programming so please be as explicit as you can :)

How to Run a Java Application Using MySQL DB on a Computer Without MySQL Installed?

I created a java application that is a front end for a MySQL Database using NetBeans and JDBC.
Now after creating the jar file it runs smoothly on my computer (Since I have the MySQL installed) but, if I run the jar on a different computer it won't work since it does not have the DB the application is using and not even MySQL installed.
So the question is, is it possible to add the database to the executable jar so it will run on any computer without the need for any installation of any software (Except for JRE of course) ?
If yes, how do I go about doing so?
Thanks everyone for the help in advance.
Use derby database. It already included in JDK's db folder when you installed the Java on your computer.
If you purely want to use the database without using the MySql then simply using the collections to create database, then you doesn't need any other database client as like MySql. But you need knowledge of Hibernate, Spring etc.

Is it possible to use derby from apache in Eclipse now that they stopped developing the derby plugin for Eclipse?

I would like to use Derby from apache in order to include database management on a desktop application that I'm currently developing.
Unfortunately I figured out that they have stopped developing this plugin and all the tutorials I've read online refer to this plugin.
So my question is, how can I use the latest version of Derby on eclipse? What steps should I follow? I would like my application to be standalone and easily transferable.
thanks in advance
Apache Derby is just like other databases that provide interface through JDBC. You don't need a specific plugin to connect with Derby. Just use the usual JDBC routines.
Basic steps:
If you want to use the latest Derby version, first you need to download it from here
You need to include the jar in your classpath.
You just need to make connections and perform queries using JDBC, as better explained at the Oracle JDBC Tutorial.
Ditto pram.
I'm using Derby in a Java app I'm developing with Eclipse, and I didn't know there was a plug-in. I connect to Derby like I would to any other database. I use the Derby command-line interface to manage the tables. \
(One feature of other db's I would have liked to see in Derby: having SQL extensions to display db metadata, like MySql's "show" and "describe" commands. Derby has these in the command-line interface, but they're apparently implemented there rather than in the SQL engine itself, so you can't use them outside of the CLI. Bummer. When I'm developing, I often build an ad hoc query screen into the app that lets me type in and execute arbitrary queries. (And no, I don't deploy this to public websites.) But I digress.)
I don't know what the plug-in does for you. I've never used an Eclipse plug-in for any database.
The plug-in is still available in source form, and instructions for building it are available on the Derby website: http://svn.apache.org/viewvc/db/derby/code/trunk/plugins/eclipse/Readme.txt?view=markup
From time to time the instructions for building the plug-in change; you might wish to check into the status of this issue for further updates: https://issues.apache.org/jira/browse/DERBY-5272

Integrating data-provider to application without using sql or nosql servers

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

Embedding mysql in java desktop application

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?

Categories

Resources