예제 #1
0
 public void insere(usuario usuario) {
   String sql = "insert into usuario (nome, email, tipo, login, senha) values(?,?,?,?,?)";
   try {
     PreparedStatement ps = getCon().prepareStatement(sql);
     ps.setString(1, usuario.getNome());
     ps.setString(2, usuario.getEmail());
     ps.setString(3, usuario.getTipo());
     ps.setString(4, usuario.getLogin());
     ps.setString(5, usuario.getSenha());
     ps.execute();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(null, "Erro SQL:" + e.getMessage());
   }
 }
예제 #2
0
  public usuario localizaMail(String email) {
    String sql = "select email,login,senha from usuario where email = '" + email + "'";
    usuario registro = new usuario();
    try {
      Statement st = getCon().createStatement();
      ResultSet rs = st.executeQuery(sql);
      if (rs.next()) {
        registro.setEmail(rs.getString("email"));
        registro.setLogin(rs.getString("login"));
        registro.setSenha(rs.getString("senha"));
      }
    } catch (SQLException e) {
      JOptionPane.showMessageDialog(null, "Erro SQL:" + e.getMessage());
    }

    return registro;
  }
예제 #3
0
  public usuario localiza(String login, String senha) {
    // tipo='" + tipo + "'
    String sql =
        "select login,senha,tipo from usuario where login='******' and senha='"
            + senha
            + "'";
    usuario registro = new usuario();
    try {
      Statement st = getCon().createStatement();
      ResultSet rs = st.executeQuery(sql);
      if (rs.next()) {
        registro.setLogin(rs.getString("login"));
        registro.setSenha(rs.getString("senha"));
        registro.setTipo(rs.getString("tipo"));
      }
    } catch (SQLException e) {
      JOptionPane.showMessageDialog(null, "Erro SQL:" + e.getMessage());
    }

    return registro;
  }
예제 #4
0
 public void atualiza(usuario usuario) {
   String sql = "update usuario set nome=?, email=?, tipo=?, login=?, senha=? where codigo=?";
   try {
     PreparedStatement ps = getCon().prepareStatement(sql);
     ps.setString(1, usuario.getNome());
     ps.setString(2, usuario.getEmail());
     ps.setString(3, usuario.getTipo());
     ps.setString(4, usuario.getLogin());
     ps.setString(5, usuario.getSenha());
     ps.setInt(6, usuario.getCodigo());
     ps.execute();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(null, "Erro SQL:" + e.getMessage());
   }
 }