- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
百度广告
2. 在JSP中的显示实现
1)显示maxRows条数据
流程如图所示:
l querymedicine. java (Medicine. querymedicine)
import javax.servlet.*;
import java.io.*;
import java.sql.*;
import Medicine.searchData;
// 接---mutiquery.jsp页面,并从request中得到5条查询条件 ///
////////////////////////////////////////////////////
private DBConnectionManager connMgr;
public void init(ServletConfig config) throws ServletException {
connMgr = DBConnectionManager.getInstance();
//========================处理 HTTP Get 请求============================
throws ServletException, IOException {
Connection con = connMgr.getConnection("medicine");
response.sendRedirect("/medicine/con_error.html");
}
// ==================== 创建数据库Statement =============================
stmt=con.createStatement();
catch (Exception e)
connMgr.freeConnection("medicine",con);
return;
//-------------------------------------------------------------
//===================从request中得到session======================
HttpSession session = request.getSession(false);
connMgr.freeConnection("medicine",con);
return;
//-----------------------------------------------------------
//======从""提交来的参数取得前页最后一条数据的药品编码=======
//如果pos=-1则表示要从头开始查
//=====================查询用的SQL语句串==========================
medtypes.dlmc, medicines.ypm, medicines.zyyx, medicines.ypzy FROM medicines,
"+ll_pos+"
and ( medtypes.dlbm = medicines.dlbm ) and ( ( medicines.del_flag = 0 ) ";
String zlbm;
String clbm;
String ypm;
synchronized (session) {
}
//===表示不是由""过来要从头开始查数据==========
synchronized (session) {
}
slist=new searchData();
//=============从设置查询条件页面取得查询条件的参数===================
dlbm=request.getParameter("dlbm");
zyyx=request.getParameter("zyyx");
//------------------------------------------------------
//=================将查询条件参数通过Vector存到session中==========
slist.setDlbm (dlbm);
slist.setZyyx (zyyx);
synchronized (session) {
}
}
else
//============================取出查询条件参数====================
zlbm=slist.getZlbm();
clbm=slist.getClbm();
ypm=slist.getYpm();
else{
stmt.setMaxRows(0);
response.sendRedirect("/medicine/session_error.html");
}
}
//=====================根据条件参数设置SQL语句=======================
if(!(zlbm.trim().equals("0"))) {
sql2+=(" and zlbm="+zlbm.trim()+"");
if(!(dlbm.trim().equals("0"))) {
sql2+=(" and dlbm="+dlbm.trim()+"");
if(!(clbm.trim().equals("0"))) {
sql2+=(" and clbm="+clbm.trim()+"");
if(!(zyyx.trim().length ()==0)) {
sql2+=(" and zyyx like %"+zyyx.trim()+"%");
if(!(ypm.trim().length ()==0)) {
sql2+=(" and ypm like %"+ypm.trim()+"%");
sqlstatment+=" )) ORDER BY medicines.ypbm ASC ";
Vector list = new Vector(); |||
stmt.setMaxRows(25);
//===================执行查询将结果放到ResultSet中================
ResultSet rs2 = stmt.executeQuery(sql2);
if(rs==null){ //如果没有查询结果数据
stmt.setMaxRows(0);
response.sendRedirect("/medicine/no_medicine.html"); //定向到一个页面
}
if(rs2.next()){
}
while(rs.next()){
m.setYpbm(rs.getInt("ypbm"));
m.setClmc(rs.getString("clmc"));
m.setYpm(rs.getString("ypm"));
m.setYpzy(rs.getString("ypzy"));
m.setDlbm(dlbm);
list.addElement(m);
//----------------------------------------------------------
stmt.setMaxRows(0);
connMgr.freeConnection("medicine",con);
synchronized (session) {
}
}catch (SQLException e){
response.sendRedirect("/Medicine/sql_error.html");
//=======================重定向到一个JSP页面==========================
ServletContext sc = getServletContext();
rd.forward(request, response);
}
// =================== 在Servlet退出时终止数据库连接,取消Statement对象
//------------------------------------------------------------------------
//========================处理HTTP Post 请求 ============================
throws ServletException, IOException {
}
//==========================取得 Servlet 信息 ============================
return "medicine.querymedicine Information";
}
function next(){
document.location="/servlet/Medicine.querymedicine?pos="+ls_pos;
function detail(ypbm){
}
责编:罗莉
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>