Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String bd = "mibase";
- String url = "jdbc:mysql://localhost:/3306"+bd;
- String password = "admin";
- String login = "root";
- try {
- Connection conn = null;
- Class.forName("org.gjt.mm.mysql.Driver");
- conn = DriverManager.getConnection(url, login, password);
- if (conn != null)
- {
- JOptionPane.showMessageDialog(null,"Conexión a base de datos "+url+" ... Ok");
- conn.close();
- }
- } catch (SQLException ex) {
- Logger.getLogger(Prueba2.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(Prueba2.class.getName()).log(Level.SEVERE, null, ex);
- JOptionPane.showMessageDialog
- (null,"Hubo un problema al intentar conectarse con la base de datos"+ex.getMessage());
- }
Add Comment
Please, Sign In to add comment