Hai everyone, i have a problem, currently i am developing software using Java (netbeans):
Currently my database looked like this:
Username and UserType
Fuhans and Administrator
Nies and 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)
{
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.
How do i solve that? Thanks