title: How to access information about specific user after login from MySQL in Java
body: <p>I've seen numerous explanations about this but in PHP. I'd like to do this in Java using JavaFX to support my GUI. I'll include my methods for Login and for showing user's name on docking station.</p>
  
  <p>So lets say that I have 10 users in my database and user <code>login_id = 5</code> logs, that means that I'd like to get all information about him on certain places (ie. first name, last name, e-mail, etc.).</p>
  
  <p><strong>LoginFXMLController</strong></p>
  
  <pre><code>@FXML
      private boolean loginSuccessful() throws SQLException{
          connection = MySQL.Connect();
          String sql = "SELECT * FROM login WHERE username = ? and password = ?";
  
          pst = connection.prepareStatement(sql);
          pst.setString(1, tfUsername.getText());
          pst.setString(2, tfPassword.getText());
          rs = pst.executeQuery();
  
          return (rs.next());
      }
  </code></pre>
  
  <p><strong>DockFXMLController</strong></p>
  
  <pre><code>@FXML
      public void showName()
      {
          try {
  // Just getting info from login_id column, and not by specific user,
  // and I'd like to change that
              String sql = "SELECT * FROM Login WHERE login_id = 1";
              pst = connection.prepareStatement(sql);
              rs = pst.executeQuery();
              if(rs.next())
              {
                  lblName.setText(rs.getString("first_name") + " " + rs.getString("last_name"));
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>This code above works and shows what it's supposed to show - first name from first row, so I have properly initialized everything that I needed.</p>