principal.labelUsuario.setText(autentica.getUsuario());
Pegar o id
package graweb;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author gustavogrativol
*/
public class classLogin {
/** Creates a new instance of ClassAutentica */
public classLogin(){
}
private String usuario;
private String senha;
//Variáveis para retornar a senha e o login encontrados no banco
private String retornaUsuario;
private String retornaSenha;
private int retornaNivel;
//======================================
public void setUsuario(String _usuario){
this.usuario = _usuario;
}
public String getUsuario(){
return this.usuario;
}
public void setSenha(String _senha){
this.senha = _senha;
}
public String getSenha(){
return this.senha;
}
public void setRetornaUsuario(String _retornaUsuario){
this.retornaUsuario = _retornaUsuario;
}
public void setRetornaSenha(String _retornaSenha){
this.retornaSenha = _retornaSenha;
}
public String getretornaLogin(){
return this.retornaUsuario;
}
public String getretornaSenha(){
return this.retornaSenha;
}
conexao.ClassConecta conexao = new conexao.ClassConecta();
telaInicial principal = new telaInicial();
public boolean autentica(){
boolean valida = true;
try{
conexao.conecta();
Statement stmt = conexao.conecta().createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM usuarios WHERE usuario = '"+ getUsuario() +"' AND senha = '"+ getSenha() +"'");
while(rs.next()){
setRetornaUsuario(rs.getString("usuario"));
setRetornaSenha(rs.getString("senha"));
}
if(getretornaLogin() == null && getretornaSenha() == null){
valida = false;
}
}catch(SQLException e){
JOptionPane.showMessageDialog(null,"Ocorreu um erro no sistema, se o problema persistir contate o administrador:\n"+ e,"ATENÇÃO",JOptionPane.WARNING_MESSAGE);
}
return valida;
}
}