Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection MySQLConnection(String user, String pass, String db_name) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + db_name, user, pass);
- System.out.println("Conectado");
- // JOptionPane.showMessageDialog(null, "Se ha iniciado la conexión con el servidor de forma exitosa");
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex);
- } catch (SQLException ex) {
- JOptionPane.showMessageDialog(null, ex.getMessage());
- }
- return conexion;
- }
- public void closeConnection() {
- try {
- conexion.close();
- // JOptionPane.showMessageDialog(null, "Se ha finalizado la conexión con el servidor");
- } catch (SQLException ex) {
- Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Add Comment
Please, Sign In to add comment