0

Sir...i am developing a java application .This app has need to connect the mysql database server.To connect the database with java we need to include mysql-connector.jar file.so i have included this and i am connecting to my database.But here the problem is After completion of this app so many users wiil use it.Does all those users need to include mysql-connector.jar file in their java directory to work this app. This app users face problem if everyone need to include that .jar file.So do we have any other way to connect the database without using any driver in java

2
  • 1
    They will use the application which will use the jar. Why would they even need to know that you're using this jar? Commented Mar 8, 2014 at 6:15
  • sir present i am developing that app in my own system and running mysql server in my system.i have sql connection driver.i have written one java file which connects to database.i have runned it in my system and class file created .i runned this class file in my syste it worked.if i runn this class file in another system does it works (i mean can that class file connect to my database with our driver in that system....) Commented Mar 8, 2014 at 6:41

4 Answers 4

1

You cannot connect to database with JDBC without using driver.

Check tutoral http://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html#step3

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

Comments

1

The MYSQL driver must reside on the classpath of the Java application that accesses the MySQL database. If the java application running on the client directly accesses MySQL, then yes, each user must have the jar.

One way to avoid this is to place the code that interacts with your database on a server, then have the client application make remote calls to that serer application.

Comments

0

If I understand the question correctly your application is under development now and will be later distributed to many users. So there are a few options you could use:

  1. Explode mysql-connector.jar and pack it with your other classes in a single jar. See Maven Assembly plugin

  2. You could also distribute your program using two JAR files, one with your code compiled and the other is mysql-connector.jar. Add a .bat or .sh script that will launch your app and add mysql-connector.jar to the classpath.

Having said the above I believe you might want to expose the data using web services. Allowing your users to access your database directly could lead to lots of issues - security, scalability, etc.

Comments

0

To connect to MySQL from Java you have to use the JDBC driver from MySQL. The MySQL JDBC driver is called MySQL Connector/J. You find the latest MySQL JDBC driver under the following URL: http://dev.mysql.com/downloads/connector/j.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.