Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1.  
  2. package util;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.SQLException;
  7. import javax.swing.JOptionPane;
  8. import model.Cliente;
  9.  
  10.  
  11. public abstract class BancoDados {
  12.  
  13. private static Connection con = null;
  14.  
  15. public static Connection conectar(){
  16.  
  17. String driver = "com.mysql.jdbc.Driver";
  18. String url = "jdbc:mysql://localhost:3306/sistema";
  19. String usuario = "root";
  20. String senha = "mysqlfatec";
  21.  
  22. //Carrega, inde inicializa o driver do banco MYSQL
  23. try{
  24. Class.forName(driver);
  25. }catch(ClassNotFoundException ex){
  26. ex.printStackTrace();
  27. }
  28.  
  29. //Conecta com o MySQL
  30. try{
  31. con = DriverManager.getConnection(url, usuario, senha);
  32. // JOptionPane.showMessageDialog(null, "Conectou com sucesso!");
  33. return con;
  34. }catch (SQLException ex) {
  35. ex.printStackTrace();
  36. return null;
  37. }
  38.  
  39.  
  40. }
  41. /*teste
  42. public static void main(String[] args) {
  43. conectar();
  44. }
  45.  
  46. */
  47.  
  48. public abstract boolean inserir(Cliente cliente);
  49.  
  50. public abstract boolean excluir();
  51.  
  52. public abstract boolean alterar();
  53.  
  54. public abstract boolean pesquisar();
  55.  
  56. public abstract boolean listar();
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement