Mẹo Hay

MySQL JDBC Driver 5.1.33 – Time Zone Issue resolved

Rate this post



This video show you how to resolve MySQL JDBC Driver 5.1.33 – Time Zone Issue.
Add to your database connection this line
useJDBCCompliantTimezoneShift=true;useLegacyDatetimeCode=false;serverTimezone=UTC;

Tag: set timezone mysql, [vid_tags]

Xem Thêm Bài Viết Về Mẹo Hay Khác: https://meocongnghe.vn/meo-hay

Nguồn: https://meocongnghe.vn

12 Comments

  1. public class ConexionDB {

    protected Connection cn = null;
    protected PreparedStatement pr = null;
    protected ResultSet rs = null;

    public ConexionDB(){
    try {
    System.out.println("Conectando a la base de datos");
    Class.forName("com.mysql.cj.jdbc.Driver");
    cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/almacenunalm?autoReconnect=true&useSSL=false&suseJDBCCompliantTimezoneShift=true;useLegacyDatetimeCode=false;serverTimezone=UTC;", "root", "mysql");
    if(Objects.nonNull(cn)){
    System.out.println("Conexion abierta [" + cn + "] ::: ok");
    }
    } catch (ClassNotFoundException | SQLException ex) {
    System.out.println(ex.getMessage());
    }
    }

    public Connection obtenerConexion() {
    return cn;
    }

    public void cerrarConexion() {
    try {
    System.out.println("Cerrando conexion a base de datos: [" + obtenerConexion() + "]");
    if (Objects.nonNull(obtenerConexion())) {
    obtenerConexion().close();
    System.out.println("Conexion cerrada");
    }
    } catch (SQLException ex) {
    System.out.println(ex);
    }

    }

    Reply

Post Comment