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 2 of 2

Thread: Problem of getting result than SQL to JTable

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem of getting result than SQL to JTable

    hi all.
    i have a program , now i add Operator manager to add new operator and get list of operator or delete
    now Add and Delete is work fine but my ResultSet dont work and give me Null pointer Exeption

    ths code in Operatormanager Class

    public ArrayList<Operator> getlist() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
     
            operators = null;
            operator= null;
     
            Command_msg = "SELECT * FROM operator";
            dbmanager.getConn();
            Statement st = dbmanager.conn.createStatement();
            ResultSet res = st.executeQuery(Command_msg); 
            while(res.next()){
                    operator.setName(res.getString("Name")); [COLOR=Red]// here is exeption[/COLOR]
                    operator.setUsername(res.getString("Username"));
                    operator.setPassword(res.getString("Password"));
                    operators.add(operator);
            }
            return operators;
        }

    and this code is in Display class

     OPManager.getlist();
                        int i = 0;
                        for (Core.Operator emp : operators) {
                            Table.setValueAt(emp.getName(), i, 0);
                            Table.setValueAt(emp.getUsername(), i, 1);
                            Table.setValueAt(emp.getPassword(), i, 2);
                            i++;
                           }

    i waiting to your Answer.


  2. #2

    Default Re: problem in get result than SQL to jtable

    It seems you have a problem with res.getString("Name"). But I need more information to help you. Your ResultSet has the Name attribute?