JDBC GUI login, textfield to local string variable <p>I have a TextField for a username named <code>username</code> and a PasswordTextField named <code>password</code>. I declared two local string variables, <code>user</code> and <code>pass</code>. I have a database but I still can't get into the "welcome" part. This is my code.</p> <pre><code>try { Class.forName("com.mysql.jdbc.Driver"); //making a connection through the driver connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/login", "root", "123456"); //System.out.println("Connected to database"); statement = connection.createStatement(); rs = statement.executeQuery("SELECT * FROM login.credentials"); while (rs.next()) { String user = rs.getString("username"); String pass = rs.getString("password"); if (username.equals(user) &amp;&amp; password.equals(pass)){ System.out.println("Welcome!"); } else { System.out.println("Invalid password!"); } } } </code></pre>