my java application setup isn't working because of database [duplicate] - java

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.

Related

Executable Java application (JAR) with database packaged inside

I am developing an application with Swing and MySql. I want to distribute it to the clients, where they could run the application on their end/PC without worrying about installing MySql and other technical stuff. So, I thought of bundling JRE and MySql but then I came across Correctly distributing a Java application with database which says it is not preferable to do so. As it would increase the application size on disk, which obviously is an issue.
So, my questions are
How do I achieve the same and what tool and resources should I use.
Is SQLite a good option?
Any help is appreciated.
In my opinion SQLite and Apache Derby (http://db.apache.org/derby/) are both good for such a plan. Some years ago i did such stuff with derby and it's still running. At that time i just packaged the folder that contained the jre, the program, libs (jar's) and the data folder of derby.
As i remember: sqlite was very easy to use whereas derby is more overhead to learn.
Please try using HsqlDb visit the link
[http://hsqldb.org/ ]
Easy to use and you can embed it into your jar.

Java local database

I am creating a piece of software using Java and Eclipse. The software is to be freestanding and not require an internet connection.
The main use of the program requires access to database. I am used to developing for Android where there is an inbuilt MySQL database in every device. Is there a similar thing with Java. I have looked everywhere and have seen references to this kind of thing but have not seen any clear answers. I know there is JDBC, but this seems to be a method of controlling the database rather than creating it.
What I am trying to establish is, is there a pre installed database available to use in Eclipse without any further installation, in the same way as the MySQL Db is available when using Android??
The version of Java I am using is java.runtime.version=1.7.0_40-b43
and I am using Eclipse Kepler Service Release 2
What I am trying to establish is, is there a pre installed database available to use in Eclipse without any further installation, in the same way as the MySQL Db is available when using Android??
First, Android includes SQLite (not mysql). Second, No. No there is not. You could use Derby or SQLite or H2 (or any other pure Java database). As pure Java databases they don't require external installation (but they can be installed externally) and can be run directly in Eclipse.
Would SQLite work for your purposes?
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
It's not pre-installed, but seems like it might be a good fit otherwise:
http://wiki.eclipse.org/Connecting_to_SQLite

Create .exe for java swing app with embedded HSQL

Recently I made an application in using Swing, HSQL Embedded that manages some database. I used HSQL as the backend to connect to the database. What I want to do is create a setup/installer program so that the application can be installed and used on any pc. My problem is I dont know how to integrate the database along?
You can use exe4j to generate .exe.
And wizard4j to create installer for your application.
Problem is that creation of exe is quite isolated case. In case of Windows, you will create msi package, in case of OSX, you will create dmg, in case of Linux, you will create rpm or tar.gz etc. Yes you could use exe4j, install4j etc. But I strongly recommend to put your jar in one specific folder, zip it and distribute in that format.
Now, when it comes to your database "integration", have a look at this question and this documentation. Reason for distributing Java application this way and not with installer come from bad experiences I encountered when writing data into flat file databases after applications get installed via install4j or exe4j.

Deployment of a Swing application that uses a database

I have created a Java Swing application with database in NetBeans IDE. I have a database created directly in NetBeans. How do I arrange that this application will be installed to run outside NetBeans IDE? For example in Windows. When I have applications without database, it is easy; but the database I do not know.
you need to install a database such as:
mysql, microsoft sql, sqlite, etc.
You can also get portable versions of these that only require an unzip and run (e.g. mysql in xampp).
You will need to create a script (either in your program or do it by hand) to create the necessary schema, and tables that are needed.
Your application must have the same credentials for both your database but also within your requests from java.
If your doing the installation by hand you usually do all the above by hand.
The database need not be on the same computer but can be on the same network or also on the internet - but it will have to be somewhere unless your using something portable like sqllite.
If your creating an automated install script you should define that in your question.

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.

Categories