相应的代码:
public ArrayList queryBusNumDetail(String busNum) {
ArrayList arrayList = new ArrayList();
DBConnection2 db = DBConnection2.getInstance();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = "";
try {
if (busNum.equals("") || busNum == null) {
sql = "select * from busInfo";
} else {
busNum = exChange(busNum);//字符串转码
sql = "select * from busInfo where busnum = '"+Integer.parseInt(busNum)+"'";
}
conn = db.getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
while (rs.next() && rs != null) {
HashMap hashMap = new HashMap();
hashMap.put("BusNum",""+rs.getInt("busnum"));
hashMap.put("BeginSt",rs.getString("beginst"));
hashMap.put("EndSt",rs.getString("endst"));
hashMap.put("TicketNote",rs.getString("ticketnote"));
hashMap.put("BusLevel",rs.getString("buslevel"));
hashMap.put("Note",rs.getString("note"));
arrayList.add(hashMap);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null) {
stmt.close();
}
db.freeConnection(conn);
} catch (Exception e) {
e.printStackTrace();
}
}
return arrayList;
}调用此方法时,在页面中先引用包com.busSystem.util,再创建QueryData类的对象,通过对象调用statisticsByBusInfo()这个方法。
〖资料来源:计算机毕业论文 www.xiaoniu168.com〗
4、站点信息查询
(1)模块功能描述
用户登录成功后即可进入到用户的个人主界面,在个人主界面,用户首先可以进行站点信息查询。站点信息查询是为用户提供按公交车某一个站点查询到该站点需要乘坐公交车的车号。该查询功能的实现也是由系统的业务逻辑层中的QueryData类来实现的。
第8页为站点信息查询模块代码实现部分......