This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • 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
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(
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>(
at inwardRecord.main(

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())
stmt is null
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!