Guest User

Untitled

a guest
Sep 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package model;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class Db {
  8.  
  9. // JDBC Drive configurações
  10. static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
  11. static final String DB_URL = "jdbc:mysql://localhost/SimpleERP";
  12.  
  13. // Credenciais para acesso ao banco de dados
  14. static final String USUARIO = "root";
  15. static final String SENHA = "";
  16.  
  17. public Db(){
  18.  
  19. }
  20.  
  21. public static void Conectar() {
  22. try {
  23. try {
  24. Class.forName(JDBC_DRIVER);
  25. System.out.println(" [ DB ] Conectando...");
  26. Connection con = DriverManager.getConnection(DB_URL, USUARIO, SENHA);
  27. System.out.println(" [ DB ] Conectado.");
  28. con.close();
  29. } catch (SQLException e) { // Connection
  30. e.printStackTrace();
  31. }
  32. } catch (ClassNotFoundException e) {
  33. e.printStackTrace();
  34. };
  35.  
  36. }
  37. }
Add Comment
Please, Sign In to add comment