====================================== //关闭数据库 public void closeDB() { try {
//System.out.println("DBConnection.closeDB( here!)" ); if(rs!=null) { rs.close(); rs = null; } else { System.out.println("rs closed!"); }//????? if(stmt!=null) { stmt.close(); stmt = null; } else { System.out.println("stmt closed!"); } if(conn!=null) { conn.close(); conn = null; } else { System.out.println("conn closed!"); } } catch(Exception ex) { //System.err.println("DBConnection.closeDB()" + ex.getMessage()); System.out.println("DBConnection.closeDB()" + ex.getMessage()); } }
}//end Class ------------------------------------------------------------------------------------二、jsp 程序中使用本类过程 1、
xml:namespace prefix = jsp />
2、处理
查询参数 iPage ,txtSearchKey
word 等
3、文章
列表:
int iPageSize = 15;//每次读行数,作为参数传入
sql 语句。。。 sql="SELECT top 200 number, sms_no, company_card_name, Reg_Date, Dead_Date, OnUse, pr + "City FROM dbo.Company_Card where 1=1 " ; if(!( txtSearchCompanyCard.equals("")))sql = sql + " and company_card_name like '%" + txtS if(!( txtSearchCity.equals("")))sql = sql + " and City ='" + txtSearchCity + "'"; sql = sql + " order by number desc "; //取得 resultset rs = conn.execQuery(sql,iPageSize,iPage); //获取记录总数 iRowCount = conn.getRowCount(); //获取总页数 iPageCount = conn.getPageCount(); //循环 do{ %">
[<%=rs.getRow()%>] | <%=rs.getString("sms_no")%> | <%=rs.getString("company_card_name")%> | <%=rs.getDate("Reg_Date")%> | <%=rs.getString("province")%> | <%=rs.getString("City")%> | ')">修改 |
<% }while(++i"); }%>
附昨天:纯 jsp 版的翻页程序代码 hi.baidu/aaa888/blog/item/7f1e249bb2ed1cb4c8eaf466.html
类别:Jsp | 添加到搜藏 | 浏览(83) 网友评论: 1 网友:alonglee - 2007-04-12 16:14 //可以输出从 1 到 iPageCount,但是没有包含查询参数 out.print(conn.showChangePage()); //输出从 1 --iPageCount 的连接 for (int i=1;i<=iPageCount;i++) { out.print( "JSP?" + "TXTSEARCHCOMPANYCARD=" + TXTSEARCHCOMPANYCARD + "&;TXTSEARCHCITY=" +
" + i + " "); } 2 alonglee - 2007-04-13 09:59 在本类中加入一个方法 public String showChangePage(String pathinfo) { //取出 hm 中的大小 //pathinfo = "file.jsp?para1=value1?2=value2" String strtempPathInfo = pathinfo + "&;iPage=" ; String strPathInfo = new String(); for (int i =1;i<=this.iPageCount;i++) { if (i==this.iPage) { strPathInfo = strPathInfo + " " + i + " | "; } else { strPathInfo = strPathInfo + " " + i + " | "; } } return strPathInfo; }
3 alonglee - 2007-04-13 10:02 jsp 中需要翻页的地方加入如下内容: 可以得到 1 2 3 4 等方式的翻页 <% //参数写到一个字符串中,带到函数中去 String nomalPathInfo = "newslist2.jsp?" + "txtSearchCompanyCard=" + txtSearchCompanyCard + "&;txtSearchCity=" + txtSearchCity ; //可以输出从 1 到 iPageCount,但是没有包含查询参数 out.print(conn.showChangePage(nomalPathInfo)); %>