I want to use MySQL for my Java app, but is very important that the user hasn't to start or install any program before start the app, so, How can I install MySQL (If it's necessary) and start the MySQL server directly by code? Have I to use other database?
MySQL has released this presentation dealing with details on how to do it if needed. It lists these three options:
Embedded library
Silent windows install
Launch mysql form command line
Check the presentation for details (the .pdf in the .zip linked at the page).
Note that you have to be licence compliant also to do this. GPL for GPL, commercial for commercial.
You can use something like the Nullsoft Scriptable Install System (NSIS) to install MySQL on the user's computer, along with your Java application. Your Java application would have to create all of the tables needed by your Java application.
Your other alternative is to use a Java embedded database, like HSQLDB. Your user would just install your Java application.
Related
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.
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.
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.
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.
I have a Java desktop application which uses mysql database . Is there any Open source software for packaging or executable wrapper of Mysql server and Java desktop application into one single Exe/Debian package where i need not separately install Mysql server separately . Its like one click installer which installs everything and the application is ready to use. Thanks
The problem here is that MySQL is a standalone server, and cannot be easily embedded. You should use an embeddable or serverless database, such as :
SQLite (see the SQLite library for Java, containing all the server and the API in one jar)
Apache Derby (see the documentation for embedded use)
HyperSQL
Just so it's said here, if you are not a Open Source project, what you are trying to do is not only a problem technically but also could be one legally. From the mySQL license agreement:
For OEMs, ISVs, VARs and Other
Distributors of Commercial
Applications:
OEMs, ISVs, VARs and other
distributors that combine and
distribute commercially licensed
software with MySQL software and do
not wish to distribute the source code
for the commercially licensed software
under version 2 of the GNU General
Public License (the "GPL") must enter
into a commercial license agreement
with Sun.
You'll probably have to script something together and use the NSIS installer builder (which is free) for Windows.
For Debian it'll be just some scripts which have to be packaged together in a .deb.
But I really don't think there is a out of the box, or off the shelf solution for this.
Good luck :)