N
N
NoMoneyException2016-12-13 08:28:08
Java
NoMoneyException, 2016-12-13 08:28:08

How to add MySQL Driver to Jar file?

I build the console server in a jar with maven, but when I run it in the console I get a SQLException

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/bankassistant?useSSL=false
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection( DriverManager.java:247)

All due to the fact that I do not know how the main application where the required driver is located.
How to add it and pack it along with everything else in a jar?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-12-13
@eugene_leshchinskiy

Try this Maven plugin here . It will allow you to build the so-called uber-jar.

D
Dmitry Zaitsev, 2016-12-13
@dim_s

There is also a plugin for Gradle that collects everything in one jar file https://github.com/johnrengelman/shadow , it is quite convenient and can resolve many conflicts correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question