Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. package lojadepc;
  2.  
  3. public class Comprador {
  4.  
  5. public String nome;
  6. public String endereco;
  7. public String telefone;
  8.  
  9. public Comprador (String nome, String endereco, String telefone) {
  10. this.nome = nome;
  11. this.endereco = endereco;
  12. this.telefone = telefone;
  13. }
  14.  
  15. public String getNome(){
  16. return nome;
  17. }
  18.  
  19. public String getEndereco(){
  20. return endereco;
  21. }
  22.  
  23. public String getTelefone(){
  24. return telefone;
  25. }
  26. }
  27.  
  28. ---------------------------------------------------------------------------------------------------------------------------------------
  29.  
  30.  
  31. package lojadepc;
  32.  
  33. import java.sql.*;
  34. import javax.swing.JOptionPane;
  35.  
  36. public class ConnectionDataBase
  37. {
  38. Connection conexao;
  39. Statement sentenca;
  40.  
  41. public Connection connect()
  42. {
  43. String url = "jdbc:postgresql://localhost:5433/postgres";
  44. String usuario = "root";
  45. String senha = "";
  46.  
  47. try
  48. {
  49. Class.forName("org.postgresql.Driver");
  50. conexao = DriverManager.getConnection(url, usuario, senha);
  51. JOptionPane.showMessageDialog(null, "Conexao realizada com sucesso!");
  52. sentenca = conexao.createStatement();
  53. sentenca.execute("SET search_path TO transacao;");
  54. }
  55. catch(ClassNotFoundException e)
  56. {
  57. JOptionPane.showMessageDialog(null, "Erro Classe:" + e.getMessage());
  58. }
  59. catch(SQLException e)
  60. {
  61. JOptionPane.showMessageDialog(null, "Erro SQL:" + e.getMessage());
  62. }
  63. return conexao;
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement