Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public void Conexion(){
  2. try{
  3. Class.forName("com.mysql.jdbc.Driver");
  4. String user= "root";
  5. String password = "";
  6. DB = "jdbc:mysql://localhost:3306/jardineria";
  7. conexion = DriverManager.getConnection(DB,user,password);
  8. if(conexion != null)
  9. {
  10. dbmd = conexion.getMetaData();
  11. System.out.println("Nombre Base de datos: " + dbmd.getURL());
  12. JOptionPane.showMessageDialog(null,"Conectado con base de datos");
  13. }
  14. } catch (ClassNotFoundException ex) {
  15. Logger.getLogger(QuerySql.class.getName()).log(Level.SEVERE, null, ex);
  16. } catch (SQLException ex) {
  17. Logger.getLogger(QuerySql.class.getName()).log(Level.SEVERE, null, ex);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement