private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String sql="Select BADGE_NUMBER,FIRST_NAME from POLICE_TABLE";
try
{
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
Connection con= (Connection) DriverManager.getConnection("jdbc:derby://localhost:1527/Traffic Ticket System","Administrator","admin1234");
/*As we are creating a connection on a local computer we will write the url as jdbc:mysql://localhost:3306 */
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
String user=jTextField1.getText();
String pwd= new String (jPasswordField1.getPassword());
while(rs.next())
{
String uname=rs.getString("FIRST_NAME");
//Username is the coloumn name in the database table
String password=rs.getString("BADGE_NUMBER");
if ((user.equals(uname)) && (pwd.equals(password)))
{
JOptionPane.showMessageDialog(null, "Welcome to the system " + uname);
JFrame frame = new JFrame();
frame.setContentPane(new Offender_Form());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Traffic Ticket System Offender Menu");
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.pack();
frame.setVisible(true);
}
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,"Cannot connect you to the database. Make sure your entering the correct First Name and Badge Number. "
+ "Please try again.");
}
}
My Table columns are set up like:
BADGE_NUMBER, DIVISION, TITLE, FIRST_NAME............
I have the following code above. I am trying to use data from my table to verify login into the database . Buts when I print the stack trace trace its telling me the table does not exist.