[阅读: 511] 2005-12-05 05:12:55
public ArrayList getAllFaults() throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet result = null;
FaultDTO item = null;
String sql_str = null;
ArrayList list = null;
sql_str = "select * from " + DataBaseTableNames.CUSRTOMERS_FAULT_REPORT
+ " order by faultID asc";
logger.debug(sql_str);
try {
conn = DatabaseConn.getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
result = stmt.executeQuery(sql_str);
if (result.isBeforeFirst()) {
list = new ArrayList();
while (result.next()) {
item = new FaultDTO();
item.setFaultID(result.getInt("faultID"));
item.setCompanlyName(result.getString("companlyName"));
item.setCompanlyAddress(result.getString("companlyAddress"));
item.setContactName(result.getString("contactName"));
item.setPhone(result.getString("phone"));
item.setMobile(result.getString("mobile"));
item.setEmail(result.getString("email"));
item.setFault(result.getString("fault"));
System.out.println("ok1");
list.add(item);
}
} else {
throw new Exception("can not read initial data in db!");
}
} catch (SQLException se) {
throw new Exception("db error ", se);
} finally {
DatabaseConn.closeAll(conn, stmt, result);
}
return list;
}