Minha classe está assim:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Teste {
public static void main(String[] args) throws SQLException {
Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/loja_virtual?useTimeZone=true&serverTimeZone=UTC", "root", "root");
System.out.println("Fechando conexão.");
conexao.close();
}
}
Depois que eu executo, o resultado é este:
Exception in thread "main" com.mysql.cj.jdbc.exceptions.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 mysql.connector.java@8.0.17/com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at mysql.connector.java@8.0.17/com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at mysql.connector.java@8.0.17/com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:827)
at mysql.connector.java@8.0.17/com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
at mysql.connector.java@8.0.17/com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237)
at mysql.connector.java@8.0.17/com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at Teste.main(Teste.java:8)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: 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 java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at mysql.connector.java@8.0.17/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at mysql.connector.java@8.0.17/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at mysql.connector.java@8.0.17/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at mysql.connector.java@8.0.17/com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
at mysql.connector.java@8.0.17/com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:340)
at mysql.connector.java@8.0.17/com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:777)
at mysql.connector.java@8.0.17/com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:486)
at mysql.connector.java@8.0.17/com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:202)
... 10 more
Caused by: javax.net.ssl.SSLHandshakeException: NotBefore: Fri Nov 27 12:44:25 BRT 2020
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:353)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:296)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:291)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:183)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:171)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1359)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1268)
at java.base/sun.security.ssl
Eu fiz o teste no Command Line Client para saber se o meu usuário e a senha estavam certos e está ok.
Desde já, agradeço pela ajuda.