problem with inserting data into database from JComboBox
here is my code
class SaveHandler4 implements ActionListener
{
String ind;
JComboBox ci;
public SaveHandler4(JComboBox ci)
{
this.ci=ci;
}
public void actionPerformed(ActionEvent ae)
{
int response = JOptionPane.showConfirmDialog(null,"Are you sure","Confirm",JOptionPane.YES_NO_OPTION);
if(response==0)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("Jdbc:Odbc:MyDataSource");
String Mysql = "INSERT into employee";
Mysql = Mysql + " (Title) ";
Mysql = Mysql + " VALUES(?) ";
PreparedStatement Ps = conn.prepareStatement(Mysql);
//ind=(String)ci.getSelectedItem();
Ps.setString(2,(String)ci.getSelectedItem());
Ps.setString(3,(String)capn.getSelectedItem());
Ps.setString(4,(String)cifc.getSelectedItem());
Ps.executeUpdate();
Ps.close();
/*tdate.setText("");
thfid.setText("");
note.setText("");
thfid.requestFocus();*/
}
catch(SQLException sq)
{
JOptionPane.showMessageDialog(null,sq.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
}
catch(ClassNotFoundException E)
{
JOptionPane.showMessageDialog(null,E.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
}
}
}
}
this is the eventhandler for a submit button that populates the database
but I get this error
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
pls help

