Hi
i have 3 classes ( users, userDAL and UsersBLL)
Everytime i trying to add record to my db i have null in all fields
This is my UsersDAL method
Java Code:
My UsersBLLpublic void criarUser(Users us) throws SQLException { String sqlCommand = "INSERT INTO USERS (UTLIZADOR, PASS, EMAIL, CARGO) VALUES('" + this.nome + "', '" + this.pass + "', '" + this.email + "', '" + this.cargo + "')"; this.dbo.executeSQL(sqlCommand); }
Java Code:
public class UsersBLL { UsersDAL us; DBAccessObj obj; public UsersBLL(){ if(us == null){ us = new UsersDAL(); } } public void criarUser(Users users) throws SQLException{ try { us.criarUser(users); } catch (Exception ex) { //tratamento de erro //tratarErro(ex); //erro para a camada superior. throw ex; } }
and finally what i use to add records
Java Code:
Is anythhing wrong in this code??private void btNovoActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String mens; UsersBLL b = new UsersBLL(); try { txt_nome.getText(); txt_pass.getText(); txt_email.getText(); combo.getSelectedItem().toString(); int resposta = JOptionPane.showConfirmDialog(null, "Os dados estão corretos?", "Aviso", JOptionPane.OK_CANCEL_OPTION); if (resposta == JOptionPane.OK_OPTION) { b.criarUser(users); mens = "Informação do User criada com sucesso!"; //javax.swing.JOptionPane.MessageDialog(null, mens, "Informação", javax.swing.JOptionPane.OK_OPTION); } else if (resposta == JOptionPane.CANCEL_OPTION) { }
Thnaks