I m designing a demo for my real application i m just testing what happen when event occur
here's my code when i press button the catch block run
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String str=jTextField1.getText();
String oldpass=new String(jPasswordField1.getPassword());
String newpass1=new String(jPasswordField2.getPassword());
String newpass2=new String(jPasswordField3.getPassword());
if(oldpass.equals("") && newpass1.equals("") && newpass2.equals("")){
JOptionPane.showMessageDialog(null,"Pls Enter the Username and password");
}
else
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/ims","root","root");
String s="select * from admin where Admin_pw=123";
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(s);
while(rs.next())
{
String y=rs.getString("Admin_id");
JOptionPane.showMessageDialog(rootPane, y);
}}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,ERROR);
}
}