I don't know if you are going to receive this tanha, but I am going to say it anyway.
What you have tried to do is wrong from the design point of view. Even if it compiles and does exactly what you want it is not how it should be done: You cannot have you entire code with different functionalities in one method. The gui you wrote should be used to do things only a gui would do. Meaning that shouldn't implement code that connects to a database, runs the query, gets the result and then perform some actions with the result inside the actionPerformed. A better way to do this (I am not saying it is the best way but it is easier and SIMPLER) is the following: (Some details are omitted in order to reduce the code)
Have a class that only returns the connection:
class ConnectDB {
public static Connection getConnection() {
//code the returns the connection to the database:
// here you write what is needed only for the connection.
// ...
conn = DriverManager.getConnection (dbUrl, dbUser, dbPass);
// .. .. ...
return conn;
}
}
Then you have another class in which you run only the queries. One method as an example
class UserDB {
public boolean validateUser(String user, String pass) {
Connection conn = ConnectDB.getConnection();
//write the query, executed, and return if the user can login or not
return false;
}
}
And finally you call the above inside your gui:
String user=textUser.getText();
String pass=textPass.getText();
UserDB udb=new UserDB();
boolean canLogin = udb.validateUser(user, pass);
What you gain from this:
An easy to read and maintain code. You have classes that do specific things, not one large method with everything inside. You can call them any time you want from wherever you want.
What if you wanted to go to another frame after the login and again you wanted to run a query. With your way you would have to write again the same code for opening connection and running the query and doing stuff with the results.
With my way all you have to do is call one method from the UserDB class. If you want you can put all your queries in one class or you can categorize them in classes:
In the class UserDB you could have methods for login inserting new user, updating and you can call them from wherever you want without having to write any extra code.
Now think this. what happens if the database's url changes or some other property changes. With your code you will have to go to all the places where you open the connection in order to change your code. With my way all you have to do is go to ONE class where you open the connection and you wouldn't have to change anything else.