File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

Please help me

Bacchi Gerem
Ranch Hand

Joined: Jan 23, 2004
Posts: 120
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

Joined: Jan 10, 2002
Posts: 56185
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Please help me
 
Similar Threads
Columns on JTable
data adapter
JDBC
Invoking ODBC database source administrator component of windows
TableModel-unable to locate error