I have these two methods. I can't seem to get it to work. The first method initializes the database connection and the second runs an other GUI after the log in procedure. I want to check if credentials are correct first before calling the GUI Class. Anybody has any suggestions on how I can achieve that?
public void getDBConnection() throws SQLException{
userid = usernameF.getText();
password = passwordF.getText();
OracleDataSource ds;
ds = new OracleDataSource();
ds.setURL(jdbcUrl);
conn = ds.getConnection(userid,password);
if(conn){
System.out.println("Connected Successfully to Database. User: " + userid);
}
else {
System.out.println("Wrong Data");
}
}
private void loginbox_actionPerformed(ActionEvent e) {
try {
getDBConnection();
}
catch (SQLException f) {
status.setText("INVALID USERNAME OR PASSWORD");
}
GUI guid = new GUI();
guid.setVisible(true);
guid.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
System.out.println(userid + " " + password);
}