Guest User

Untitled

a guest
Aug 17th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. String bd = "mibase";
  2. String url = "jdbc:mysql://localhost:/3306"+bd;
  3. String password = "admin";
  4. String login = "root";
  5. try {
  6. Connection conn = null;
  7. Class.forName("org.gjt.mm.mysql.Driver");
  8. conn = DriverManager.getConnection(url, login, password);
  9. if (conn != null)
  10. {
  11. JOptionPane.showMessageDialog(null,"Conexión a base de datos "+url+" ... Ok");
  12. conn.close();
  13. }
  14. } catch (SQLException ex) {
  15. Logger.getLogger(Prueba2.class.getName()).log(Level.SEVERE, null, ex);
  16. } catch (ClassNotFoundException ex) {
  17. Logger.getLogger(Prueba2.class.getName()).log(Level.SEVERE, null, ex);
  18. JOptionPane.showMessageDialog
  19. (null,"Hubo un problema al intentar conectarse con la base de datos"+ex.getMessage());
  20. }
Add Comment
Please, Sign In to add comment