Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Problem with DAL and BLL classes

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with DAL and BLL classes

    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:

    public 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);
    }
    My UsersBLL

    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:

    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) {
                }
    Is anythhing wrong in this code??

    Thnaks


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Problem with DAL and BLL classes

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/75109-problem-dal-bll-classes.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with DAL and BLL classes

    OK Kevin

    I won't do it again.

    regards

Similar Threads

  1. Replies: 6
    Last Post: February 24th, 2012, 09:45 PM
  2. [SOLVED] Small problem regarding inheritance of classes
    By Stockholm Syndrome in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 10th, 2011, 02:11 PM
  3. Problem with Java Classes, in an applet
    By SashaThompson in forum Object Oriented Programming
    Replies: 12
    Last Post: October 2nd, 2011, 07:15 AM
  4. Classes problem
    By Skyton in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 3rd, 2011, 03:26 PM
  5. Problem to organize my code in classes
    By lumpy in forum Java Theory & Questions
    Replies: 2
    Last Post: February 21st, 2010, 12:13 PM