aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Issue with Combo box when fetching the data from database and populating the other combo box. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Issue with Combo box when fetching the data from database and populating the other combo box." Watch "Issue with Combo box when fetching the data from database and populating the other combo box." New topic
Author

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

Mayur Saparia
Greenhorn

Joined: Feb 13, 2013
Posts: 19

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)


Thanks In advance

Regards
Mayur.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with Combo box when fetching the data from database and populating the other combo box.