Este eh a classe UsuarioDAO:
import generico.AccessJDBCUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class UsuarioDAO {
private Connection con;
private PreparedStatement ps;
public UsuarioDAO() {
try {
con = AccessJDBCUtil.getAccessDBConnection("D:\NetBeansProjects\TrabAlgo\musicas.mdb");
} catch (SQLException ex) {
ex.printStackTrace();
}
}
public boolean verificaLogin(Usuario usuario) {
boolean achou=false;
try {
ps = con.prepareStatement("SELECT FROM * usuarios WHERE usuario = ? AND senha = ?");
ps.setString(1, usuario.getLogin());
ps.setString(2, usuario.getSenha());
ResultSet rs = ps.executeQuery();
if(rs.next()){
CadastroMusicas cm = new CadastroMusicas();
cm.setVisible(true);
}else{
achou=false;
JOptionPane.showMessageDialog(null, "Nome de Usuáio ou senha inválidos");
}
} catch (SQLException ex) {
ex.printStackTrace();
achou=false;
}
return achou;
}
}
Esta eh a classe Login onde teria que ser chamado o metodo verificaLogin, que não estou conseguindo chamar.
public class Login extends javax.swing.JFrame {
/** Creates new form Cadastros */
public Login() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
btnLogar = new javax.swing.JButton();
btnLimpar = new javax.swing.JButton();
btnSair = new javax.swing.JButton();
campoLogin = new javax.swing.JTextField();
campoSenha = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Cadastro de Músicas Versão 1.0");
jLabel2.setText("Login:");
jLabel3.setText("Senha:");
btnLogar.setMnemonic('E');
btnLogar.setText("Entrar");
btnLogar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLogarActionPerformed(evt);
}
});
btnLimpar.setMnemonic('L');
btnLimpar.setText("Limpar");
btnLimpar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLimparActionPerformed(evt);
}
});
btnSair.setMnemonic('S');
btnSair.setText(" Sair ");
btnSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSairActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(57, 57, 57)
.addComponent(btnLogar)
.addGap(18, 18, 18)
.addComponent(btnLimpar)
.addGap(18, 18, 18)
.addComponent(btnSair)
.addContainerGap(70, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(101, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(97, 97, 97))
.addGroup(layout.createSequentialGroup()
.addGap(78, 78, 78)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(9, 9, 9))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(campoSenha)
.addComponent(campoLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
.addContainerGap(127, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jLabel1)
.addGap(57, 57, 57)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(campoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(campoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnLogar)
.addComponent(btnLimpar)
.addComponent(btnSair))
.addContainerGap(70, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void btnLimparActionPerformed(java.awt.event.ActionEvent evt) {
campoLogin.setText("");
campoSenha.setText("");
}
private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}
private void btnLogarActionPerformed(java.awt.event.ActionEvent evt) {
// teria q chamar aqui o metodo qdo eu clica no botão logar
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnLimpar;
private javax.swing.JButton btnLogar;
private javax.swing.JButton btnSair;
private javax.swing.JTextField campoLogin;
private javax.swing.JTextField campoSenha;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
// End of variables declaration
}
eh isso… agradeço a atenção…