<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionDateBase {
public static final String DB_URL = "jdbc:mysql://localhost:3306/chat";
public static final String H2_DRIVER = "com.mysql.jdbc.Driver";
public static final String LOGIN = "root";
public static final String PASSWORD = "app112";
public ConnectionDateBase() {
}
public Connection getConnection() throws SQLException, ClassNotFoundException {
Class.forName(H2_DRIVER);
return DriverManager.getConnection(DB_URL, LOGIN, PASSWORD);
}
}
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
<packaging>war</packaging>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
private static final String URL = "jdbc:mysql://localhost:3306/testsql?useUnicode=true&useSSL=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Driver driver = new com.mysql.cj.jdbc.Driver(); // .cj. - внимательно -2 варианта
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.5.0</version>
<configuration>
<mainClass>mainFx.Main</mainClass>
</configuration>
</plugin>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.3</version>
</dependency>