Cannot get Strings to Match
I am trying to check for a usertype condition but nothing I try works. Please help
This is my code that checks for match. Note the System.out.println always outputs "NoMatch" even when usertype1 = "Administrator"
package com.ibm.drawinginquiry.rational;
import java.sql.*;
import com.ibm.as400.access.*;
publicclass LogOnConnection{
public String userfname;
public String userlname;
public String usertype1;
public String username;
public String userpassword;
public String unEncriptedpassWord;
public UserInfo userInfo;
public LogOnConnection(String arg0, String arg1){
AS400JDBCDataSource datasource =new AS400JDBCDataSource("gvas400");
datasource.setUser("id");
datasource.setPassword("password");
try
{
Connection connection = datasource.getConnection();
String sql ="SELECT * FROM webprddt6.appusrprf1 WHERE usrid1 = '" + arg0.toUpperCase() +"'";
Statement sment = connection.createStatement();
ResultSet rs = sment.executeQuery(sql);
if(rs.next()){
userfname = rs.getString("fname");/* the column index can also be used */
userlname = rs.getString("lname");
usertype1 = rs.getString("usrtype1");
username ="Welcome " + userfname+userlname+"- "+usertype1;
userpassword = rs.getString("pword");
UserType usertype2 = UserType.getUType(usertype1);
PasswordClass unEncriptedpassWord = PasswordClass.getPword(userpassword);
if (arg1.equals(unEncriptedpassWord.getPassWord())){
if("Administrator".equals(usertype2.getUserType())){
System.out.println("Match");
}
else{
System.out.println("NoMatch");
}
}
else{
username ="Welcome You are logged on as a Guest2!";
userpassword ="";
usertype1 ="Guest";
rs.close();
sment.close();
}
}
else{
username ="Welcome You are logged on as a Guest!";
userpassword ="";
usertype1 ="Guest";
rs.close();
sment.close();
}
}
catch (SQLException se)
{
System.err.println("Exception creating the database connection: "+se);
}
}
}
This is my UserType class
package com.ibm.drawinginquiry.rational;
publicclass UserType{
private String userType;
public UserType(String userType){
this.userType = userType;
}
public String getUserType(){
return this.userType;
}
publicstatic UserType getUType(String userType){
returnnew UserType(userType);
}
}

