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: a gain! NullPointerException, need help

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post a gain! NullPointerException, need help

    dear Master...

    i meet " Exception in thread "main" java.lang.NullPointerException" in my code.
    Before i post this tread, i have read some post about NullPointerException. I try to undersatanding it, but when i implement to my code, i still confuse... hahaha

    finaly, i make a new post about myproblem. please for anybody to help me. What's wrong with mycode?

    Exception in thread "main" java.lang.NullPointerException
            at aplikasiBarang.prosesCari(aplikasiBarang.java:575)
            at aplikasiBarang.tampilTabel(aplikasiBarang.java:608)
            at aplikasiBarang.<init>(aplikasiBarang.java:303)
            at aplikasiBarang.main(aplikasiBarang.java:780)

    this is code for at aplikasiBarang.prosesCari(aplikasiBarang.java:575)
    void prosesCari(String sql)
    {
        tabelKosong();
        int a=1;
        try
        {
            Connection connect=new koneksiDb().condb();
            Statement stat = connect.createStatement();
            ResultSet rset = stat.executeQuery(sql);
            while(rset.next())
            {
                String kode=rset.getString(1);
    ....
    ...
    ..
    .
     txtkode.setEnabled(false);
     tblbarang.setEnabled(false);
     tcari.setEnabled(false);
     bcari.setEnabled(false);
     bprev.setEnabled(false);
     bnext.setEnabled(false);
     teksFalse();
     tombolFalse();
     koneksiDb koneksi=new koneksiDb();
     koneksi.panggilDriver();
     tampilTabel(); // ==> when i click[COLOR="Blue"](aplikasiBarang.java:303)[/COLOR], the highlight foucus in here.
    }

    and the last is code for at aplikasiBarang.main(aplikasiBarang.java:780)
        public static void main(String[] args) {
            aplikasiBarang tampilan = new aplikasiBarang();
            tampilan.setTitle("Program Aplikasi Adventori Barang");
            tampilan.setSize(440,530);
            Dimension layar=Toolkit.getDefaultToolkit().getScreenSize();
            int l=(layar.width-tampilan.getSize().width)/2;
            int t=(layar.width-tampilan.getSize().width)/2;
            tampilan.setLocation(l,t);
            tampilan.setResizable(false);
            tampilan.setVisible(true);
            tampilan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: a gain! NullPointerException, need help

    I encourage you to break the problem down into a short, compilable example that demonstrates the problem. You can start from the ground and get something that works then add things back, or work top down and remove elements until the exception is gone (which typically leads you directly to the cause). The code as posted is limited, line numbers do not match up, and makes it hard to diagnose the problem.

Similar Threads

  1. Problem with NullPointerException?
    By scooty199 in forum What's Wrong With My Code?
    Replies: 15
    Last Post: November 6th, 2010, 05:13 PM
  2. [SOLVED] Nullpointerexception
    By kbwalker87 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 14th, 2010, 10:33 PM
  3. [SOLVED] NullPointerException
    By javapenguin in forum What's Wrong With My Code?
    Replies: 13
    Last Post: October 1st, 2010, 12:10 AM
  4. NullPointerException
    By bbr201 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 29th, 2010, 07:06 PM
  5. NullPointerException in Java
    By jazz2k8 in forum Exceptions
    Replies: 9
    Last Post: June 1st, 2008, 05:59 PM