Results 1 to 2 of 2
  1. #1
    Fuhans is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Login in java show all user and all usertype

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

    Login in java show all user and all usertype-capture.png

    When i login with Username: Nies

    The program respond, but it gave me the dialog box where all of the 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:

    Java Code:
    private void GetUsername(Connection conn, Statement state, ResultSet result)
        {
            try
            {
                String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
                Class.forName(driver);
    
                String url = "jdbc:odbc:Database";
    
                conn = DriverManager.getConnection(url);
    
                state = conn.createStatement();
    
                String query = "select * from Member";
    
                result = state.executeQuery(query);
    
                while(result.next())
                {
                    user = result.getString("Username");
                    userType = result.getString("UserType");
    
                    _userInformation.setUser(user);
                    _userInformation.setUserType(userType);
    
                    _sound.PlaySound(1);
                    _infoBox.ShowMessageBox("Welcome! " + _userInformation.getUser() + " - " + _userInformation.getUserType() + " ", "Welcome" , 1);
                }
            } 
    
            catch (Exception e) 
            {
                System.err.println(e.getMessage());
    
                _sound.PlaySound(2);
    
                _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);
    
                System.exit(0);
            }
        }
    _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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: Login in java show all user and all usertype

    Closing this duplicate.
    Please only post your questions once.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 09-15-2013, 05:24 PM
  2. Java with MS Access Database User login
    By pateldpk in forum JDBC
    Replies: 2
    Last Post: 04-20-2012, 03:24 PM
  3. Single user Login authentication
    By vinoopraj in forum Web Frameworks
    Replies: 0
    Last Post: 07-20-2010, 08:19 AM
  4. Query for User Login Information
    By nwboy74 in forum Advanced Java
    Replies: 3
    Last Post: 06-23-2010, 10:07 PM
  5. Login user name - for all platforms.
    By Eranga in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 05:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •