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

    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)
                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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

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

    Well then change your select statement so it only selects the required user.
    At the moment you are selecting everything in that table and then looping over the result, displaying each one in a message box.

    Also, why does your method take in those parameters, only to assign them in the method itself?
    May as well remove the parameters.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Login in java show all user and all usertype
    By Fuhans in forum New To Java
    Replies: 1
    Last Post: 11-18-2013, 01:35 PM
  2. Replies: 0
    Last Post: 09-15-2013, 06:24 PM
  3. Java with MS Access Database User login
    By pateldpk in forum JDBC
    Replies: 2
    Last Post: 04-20-2012, 04:24 PM
  4. Single login for a user at a time
    By mitali l joshi in forum Java Servlet
    Replies: 4
    Last Post: 01-22-2010, 11:23 AM
  5. Login user name - for all platforms.
    By Eranga in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 06: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