While running this code I get "JAVA error"
And in the console I see
- Connection to db
- Connection suceeded
- Select * from project.user
- 1
- java.lang.NullPointerException
- ...
- ...
- ...
- java.lang.NullPointerException
public void showuser(){
System.out.println("Connection to db");
try {
Connection con = DriverManager.getConnection(url, "", "");
System.out.println("Connection suceeded");
String sql = "Select * from project.user";
System.out.println(sql);
Statement st = con.createStatement();
ResultSet rs= st.executeQuery(sql);
String title[]={"ID","Name","Status","Nomber","Balance","Login","Password"};
DefaultTableModel aModel = new DefaultTableModel();
aModel.setColumnIdentifiers(title);
int i=0;
while (rs.next())
{ Object objects[]= new Object[7];
i=0;
while(i<7)
{
objects[i]=rs.getObject(i+1);
System.out.println(objects[i].toString());
i++;
}
aModel.addRow(objects);
}
jTable1.setModel(aModel);
con.close();
}
catch (SQLException ex)
{
while(ex!= null)
{
ex=ex.getNextException();
}
JFrame f1= new JFrame();
JOptionPane.showMessageDialog(f1,"SQL error");
System.out.println(ex);
}
catch (java.lang.Exception ex)
{
ex.printStackTrace();
JFrame f1= new JFrame();
JOptionPane.showMessageDialog(f1,"JAVA error");
System.out.println(ex);
}
}