Connecting to the MySQL database on another server via the Internet.

When running in Intellij IDEA (IntelliJ IDEA 2016.1.2 Build # IC-145.972, built on May 14, 2016) everything is fine - there are no errors. But, when you run the compiled jar, an error appears connecting to the database:

java.sql.SQLException: No suitable driver found for jdbc:mysql://xxx.xxx.xxx.xxx:3306/BaseName 

I assume that the library is not included in the executable file.

But in the project properties in "Global librires" it is indicated "mysql: mysql-connector-java: 5.1.39".

When added to "Librires", "Project setting" from Maven reports an unused library and offers to delete it.

How to make so collected jar saw the driver for jdbc?

    1 answer 1

    Add to project file: ИмяПроекта/.idea/artefacts/Имяпроекта_jar.xml

    line:

     <element id="extracted-dir" path="$PROJECT_DIR$/lib/mysql-connector-java-5.1.39.jar" path-in-jar="/" /> 

    Accordingly, in the lib folder the file mysql-connector-java-5.1.39.jar should be present.