Advertisement
Guest User

Untitled

a guest
Feb 1st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. package Modelo;
  2.  
  3.  
  4. public class Login {
  5.  
  6. private String nome;
  7. private String senha;
  8.  
  9.  
  10. public String getNome() {
  11. return nome;
  12. }
  13.  
  14.  
  15. public void setNome(String nome) {
  16. this.nome = nome;
  17. }
  18.  
  19.  
  20. public String getSenha() {
  21. return senha;
  22. }
  23.  
  24.  
  25. public void setSenha(String senha) {
  26. this.senha = senha;
  27. }
  28.  
  29.  
  30. }
  31.  
  32.  
  33.  
  34.  
  35. Segue a minha Conexão
  36.  
  37.  
  38. package Modelo;
  39.  
  40. import java.sql.*;
  41. import java.sql.DriverManager;
  42. import java.sql.ResultSet;
  43. import java.sql.SQLException;
  44. import java.sql.Statement;
  45.  
  46.  
  47. public class Conexao {
  48.  
  49. public Statement stm;
  50. public ResultSet rs;
  51.  
  52. public static final String URL = "jdbc:mysql://localhost:3306/gestaosenha";
  53. private static final String driver = "com.mysql.jdbc.Driver";
  54. public static final String USER = "root";
  55. public static final String SENHA = "12345";
  56.  
  57. public Connection conn;
  58.  
  59. public static Connection Conectar()
  60. throws SQLException
  61. {
  62. try {
  63. System.setProperty("jdbc.Drivers",driver);
  64.  
  65. return DriverManager.getConnection(URL, USER, SENHA);
  66. } catch (SQLException se) {
  67. throw new SQLException("Erro ao conectar"+se.getMessage());
  68.  
  69. }
  70.  
  71. }
  72. }
  73.  
  74.  
  75.  
  76. Segue o View
  77.  
  78.  
  79. private void EntrarMouseClicked(java.awt.event.MouseEvent evt) {
  80. // TODO add your handling code here:
  81. if ((jtextfildNome.getText().isEmpty()) || (jPasswordField1Senha.getText().isEmpty())) {
  82.  
  83. JOptionPane.showMessageDialog(null, "Preencha os campos Nome e Senha" );
  84. }
  85. else
  86. {
  87. JOptionPane.showMessageDialog(null, "O USUÁRIO " + jtextfildNome.getText() + " LOGOU" );
  88. dispose();
  89.  
  90. new Administrador ().setVisible(true);
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement