Home:ALL Converter>Connecting to mysql database with java

Connecting to mysql database with java

Ask Time:2014-03-08T14:14:00         Author:vijay b

Json Formatter

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

Author:vijay b,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22265845/connecting-to-mysql-database-with-java
qwazer :

You cannot connect to database with JDBC without using driver.\n\nCheck tutoral \nhttp://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html#step3",
2014-03-08T06:19:02
user3395335 :

The MYSQL driver must reside on the classpath of the Java application that accesses the MySQL database.\nIf the java application running on the client directly accesses MySQL, then yes, each user must have the jar.\n\nOne 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. ",
2014-03-08T06:19:59
Vladimir G. :

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: \n\n\nExplode mysql-connector.jar and pack it with your other classes in a single jar. See Maven Assembly plugin \nYou 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.\n\n\nHaving 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.",
2014-03-08T06:53:47
yy