Login in java show all user and all usertype RRS feed

  • Question

  • i have a problem, currently my database looked like this:

    ID Username UserType

    1 Nies Administrator 2 Trinity Member

    When i login with Username: Nies

    The program respond, but it gave me the dialog box where both Username are displayed. I want only when i login with Username: Nies, the program also gave me the dialog box where only that Username will be displayed..

    How do i fix that?

    Here is the code that display a username and dialog box:

    private void GetUsername(Connection conn, Statement state, ResultSet result)
                String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
                String url = "jdbc:odbc:Database";
                conn = DriverManager.getConnection(url);
                state = conn.createStatement();
                String query = "select * from Member";
                result = state.executeQuery(query);
                    user = result.getString("Username");
                    userType = result.getString("UserType");
                    _infoBox.ShowMessageBox("Welcome! " + _userInformation.getUser() + " - " + _userInformation.getUserType() + " ", "Welcome" , 1);
            catch (Exception e) 
                _infoBox.ShowMessageBox(e.getMessage(), "Error", 2);
                _reminder = new Reminder(1);
                JOptionPane.showOptionDialog(null, "Program will be closed due to error", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);

    _infoBox.ShowMessageBox is the instance ShowMessageBox function inside InfoBox class where that function store JOptionPane.

    I want only the current login user in the program that will be detected, not all the users in the database.

    How do i solve that? Thanks

    Sunday, November 17, 2013 11:13 AM