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?
Code :
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)
Code :
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)
Code :
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);
}
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.