Conexion entre netbeans y mysql
Publicado por Mateo (4 intervenciones) el 30/10/2019 23:53:42
Hola Amigos de lawebdelprogramador alguien me podria explicar a que se debe este error.

Valora esta pregunta


0
import java.sql.*;
public class Conexion {
private static Connection cnx = null;
public static Connection obtener() throws SQLException, ClassNotFoundException {
if (cnx == null) {
try {
cnx = DriverManager.getConnection("jdbc:mysql://localhost/java_mysql", "juan", "12345");
} catch (SQLException ex) {
throw new SQLException(ex);
} catch (ClassNotFoundException ex) {
throw new ClassCastException(ex.getMessage());
}
}
return cnx;
}
public static void cerrar() throws SQLException {
if (cnx != null) {
cnx.close();
}
}
}