• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with Combo box when fetching the data from database and populating the other combo box.

 
Mayur Saparia
Greenhorn
Posts: 19
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
In my application I have one combo box named custName which has the customer Name coming from the database, and i have given it actionlistener and when action is performed I am firing a query using the item selected from the combo box. But its not working for me I am wondering what the error is ?






Error Given by eclipse is :
Exception in thread "main" java.lang.NullPointerException
at inwardRecord.actionPerformed(inwardRecord.java:314)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.contentsChanged(Unknown Source)
at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
at javax.swing.DefaultComboBoxModel.setSelectedItem(Unknown Source)
at javax.swing.DefaultComboBoxModel.addElement(Unknown Source)
at javax.swing.JComboBox.addItem(Unknown Source)
at inwardRecord.<init>(inwardRecord.java:265)
at inwardRecord.main(inwardRecord.java:296)

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looks like you have this in your variables declaration section
Statement stmt;

then this in the try block of the constructor
Statement stmt = con.createStatement();//local to the try block

so, when you try to use stmt (in actionPerformed())
rs1=stmt.executeQuery(query2);
stmt is null
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic