0

I`m an Android developer, and recently started working on JAVA PC project for client.

I wish to use MySQL database at my project but i`m little rusty at this. Before I start learning and remembering how to connect SQL with Java, i would like to ask an important question.

After I export Executable JAR file for my client, the file will include MySQL connection? I mean will the client have to install MySQL on his PC and import the DB or something extra except java for running JAR file.

1 Answer 1

1

Depends where DB is running:

If it is an external server that is available over LAN/internet the client only needs the DB driver (search for mysql connector/J).

Otherwise, if the DB is to be run locally, the client needs to install mysql (and then still your program needs the Connector/J in classpath). I don't think you can pack a mysql DB in a jar. But you probably can package a SQL script that fills the DB with some initial data.

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

4 Comments

Thank you for the answer. Can you please recommend some solution that the program will use DB but with minimal hassle for the user. I would like to send the client jar file (or wrap it with executable file that will install java) maybe with some data folders. The DB have to run locally. The simple way for me is to use XML or TXT files for my DB but I don't think that is the right way.
Apache Derby and H2 can be embedded into java applications what makes them invisible to the end user. JavaDB (Oracles distribution of Derby) is shipped with JDK7, afaik. If you have to use MySql, then I think there is now other way than to make the user install MySql, too.
You actually can package the driver in the jar, In eclipse, right click the project and choose export as runnable jar that will package all referenced libraries as well.
JavaDB (Oracles distribution of Derby) is also invisible to the end user? Packaging the driver in the jar, and exporting as runnable jar will save my referenced libraries like MySQL DB tables?

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.