Bookmark Topic Watch Topic
  • New Topic

Please help me

 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I need help .In the following code "else " part code is not working.
My idea is

If there is no record exists dataadapter is null.
else dataadapter has one reord.
How can i do that.please help me


Thanks

My code:


public class AdminModel extends AbstractModel {

public DataAdapter processRequest() throws Exception {
String[] columnNames = new String[] { "User Name "};
Class[] columnTypes = new Class[] { Constants.DATA_TYPE_STRING };
DataAdapter da = new DataAdapter(columnNames.length);
da.setDesc("Admin");
da.setColumnNames(columnNames);
Connection con = getDBConnection();
StringBuffer sqlCmd = new StringBuffer();
AddMachinesSelection ins = AddMachinesSelection.getInstance();
sqlCmd.append("SELECT LOGIN_ID from PMI_User_Name_Map where Login_Id =");
sqlCmd.append("'" + ins.getUserName() + "'");
sqlCmd.append(" AND PMI_User_Name = 'ADMIN' ");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlCmd.toString());
System.out.println(rs.wasNull());
System.out.println(sqlCmd.toString());
//da.addGroup("");
if(!rs.wasNull()) {
da = null;
}
else {
da.addGroup("");
Vector row = new Vector();
System.out.println(rs);
row.add(ins.getUserName());
da.addOneRow(row);
System.out.println(row);
System.out.println(da);
}
rs.close();
stmt.close();
return da;
}
public static void main(String[] args) {
Environment env = Environment.getInstance();
env.setStandalone(true);
env.setDbLocation("C:\\Program Files\\VIMSDataPro\\Data\\VIMS.mdb");
env.setDev(true);
ClientRequest res = new ClientRequest("AdminModel");

try {
DataAdapter data = (DataAdapter) res.request();
data.dump();
} catch (Exception e) {
System.out.println("Error: " + e);
}
System.exit(0);
}
}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bhaskar, you have already asked this question here.

Please do not post the same question more than once in the same, or across multiple forums.

You might also want to rethink your choice of titles. "need help" is not very descriptive and few people will bother reading your post without a descriptive title.

bear
Forum bartender
 
    Bookmark Topic Watch Topic
  • New Topic