相应代码:
public ArrayList queryStInfo(String stname) {
ArrayList arrayList = new ArrayList();
DBConnection2 db = DBConnection2.getInstance();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = "";
try {
stname = exChange(stname);//字符串转码
conn = db.getConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql="selectbusInfo.busnum,busInfo.BeginSt,busInfo.EndSt,busInfo.TicketNote,stInfo.stname from busInfo,stInfo,busst where stname like '%"+stname+"%' and stInfo.stid = busst.stid and busst.busnum = busInfo.busnum";rs = stmt.executeQuery(sql);
while (rs.next() && rs != null) {
HashMap hashMap = new HashMap();
hashMap.put("BusNum",""+rs.getInt("busnum")); //将从数据库中查出的值放入hashmap中
hashMap.put("BeginSt",rs.getString("BeginSt"));
hashMap.put("EndSt",rs.getString("EndSt"));
hashMap.put("TicketNote",rs.getString("TicketNote"));
hashMap.put("StName",rs.getString("stname"));
arrayList.add(hashMap); //将所有的hashmap放入arrayList
}
} 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类的对象,通过对象调用queryStInfo()这个方法。〖资料来源:计算机毕业论文 www.xiaoniu168.com〗
5、公交换乘方案查询
(1)模块功能描述
用户登录成功后即可进入到用户的个人主界面,在个人主界面,用户首先可以进行公交换乘方案的查询。公交换乘方案查询即为用户输入起始站点和目的站点,然后点击查询搜索乘车路线确定换乘的方案。
第9页为公交换成模块代码实现部分......