2

I have prepared an application that is a small demo of Student information manipulation. I have stored information related to students in a MySQL DB. Now my application is working 100% on my computer. But I want that work everywhere without depending on Database! I mean I just want "WHEREVER MY .JAR FILE GOES, DATABASE SHOULD ALSO GO ALONG WITH THAT INSIDE .JAR FILE "

So anyone who is using my application or trying it, they can realize exact result of this application.

How can I make this possible? Please someone help me.

For that I have done the following things:

I have installed MySQL database on my computer.

I have created a database on that MySQL server

I have created some tables in the database with a lots of data.. this data is to be used in my whole application, even for login.

Now I want to deliver this application to various clients but my clients are not technical persons and I don't want to give instructions to each of my client to do the above four steps.

How can I integrate some functionality into my app so that they can use my database, Tables and Data automatically .

It would be much better if the code can install the MySQL database automatically from the setup file attached with the application.

How the applications available in the market manage information

2
  • 2
    Simple answer: No you can't put a database within your jar file. But! You can use some type of embedded database. Have a look at this question. I.e. in case of embedded Derby, your database will be created only once (If it doesn't exist. You can also set your app to create tables if they don't exist) within folder where your jar file is placed. Commented Oct 11, 2013 at 15:37
  • P.S. Although a duplicate, this is an excellent question. Commented Oct 11, 2013 at 15:51

2 Answers 2

1

Have you thought of using another database engine? MySQL requires the server to be installed and configured, and it is a huge task to be done by an automatic installer. What about using for example SQLite http://www.sqlite.org/ or Apache Derby http://db.apache.org/derby/. Both of them work by creating a file in your working dir, you could setup the database and populate data at install time

Sign up to request clarification or add additional context in comments.

2 Comments

This question is more then a duplicate. And also, makes me wonder where is a big difference between your answer and mine comment.
is this possible to all convert my Mysql database into sqlite.. please suggest me
0

I have two suggestions for you:

A. Use SQLite instead of MySQL. SQLite is an embeddable database engine and does exactly what you need. You can simply copy the .sqlite file where all the information is stored and distribute it with your JAR file. Given that you've already written you app to use MySQL, this could mean making a few changes to your code.

There is a good SQLite jdbc driver at: https://bitbucket.org/xerial/sqlite-jdbc

I've used it before, though not extensively.

B. Use a portable installation of MySQL. If you are using Windows these are available on the MYSQL page, look for the downloads marked "ZIP Archive" instead of "MSI Installer". These versions are portable in that they do not require an installation process, just unzip the file, and start the service. Your clients need to know how to start it up, of course. Perhaps you could create a shortcut for that.

Of course, the idea of MySQL being a network server is so that everyone in the enterprise works with the same data, by connecting to the same server. If your clients will use this application in various computers in the same company, you should consider having a single MySQL Server installed, and making the clients connect to that.

Hope this helps!

3 Comments

Or create hell of a help file for user which explains how to install everything! :)
can i use dump files for moving my data.. because on another system there would also mysql server.. i mean there is no problem of installation of mysql setup..just 1 main thing is that i do not have enough time to change my database to sqlite
@brano88 i cannot give them a help file.. there is no point of creating all tables and inserting mb's of data in them on which my whole project is running..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.