📄 tphmbrandlistimpl.java
字号:
package com.sxit.phonemanager;
import com.sxit.common.ListImpl;
import java.util.*;
import java.sql.*;
/**
* <p>类名: TphmbrandListImpl</p>
* <p>功能: 品牌</p>
* <p>公司: 深讯信科</p>
* <p>版本: 1.0</p>
* @程序 sxit
* @日期 2005-03-22
* @修改纪录
*/
public class TphmbrandListImpl extends ListImpl
{
public TphmbrandListImpl()
{
super();
}
/**
* 创建全部列表
*/
public void createList(Connection con) throws SQLException
{
createList(con,0,0,"");
}
/**
* 有条件创建全部列表
*/
public void createList(Connection con,String strSearch) throws SQLException
{
createList(con,0,0,strSearch);
}
/**
* 创建分页列表
*/
public void createList(Connection con,int pageNo,int pageSize) throws SQLException
{
createList(con,pageNo,pageSize,"");
}
/**
* 有条件创建分页列表
*/
public void createList(Connection con,int pageNo,int pageSize,String strSearch) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
int i=0;
try{
if(pageNo==0 && pageSize==0){
strSearch=" where 1=1 "+strSearch;
recList=new ArrayList();
sql="select brandid,brandname from tphmbrand "+strSearch;
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
i=0;
while(rs.next()){
Tphmbrand tphmbrand=new Tphmbrand();
tphmbrand.setBrandid(rs.getLong("brandid"));
tphmbrand.setBrandname(rs.getString("brandname"));
recList.add(tphmbrand);
i++;
}
stmt.close();
}else{
this.pageNo=pageNo;
this.pageSize=pageSize;
recList=new ArrayList();
sql="select brandid,brandname from tphmbrand "+strSearch;
stmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery();
rs.last();
recCount=rs.getRow();
if(pageSize*(pageNo-1)==0){
rs.beforeFirst();
}else{
rs.absolute(pageSize*(pageNo-1));
}
i=0;
while(rs.next() && i<pageSize){
Tphmbrand tphmbrand=new Tphmbrand();
tphmbrand.setBrandid(rs.getLong("brandid"));
tphmbrand.setBrandname(rs.getString("brandname"));
recList.add(tphmbrand);
i++;
}
stmt.close();
// this.pageNo=pageNo;
// this.pageSize=pageSize;
// strSearch=" where 1=1 "+strSearch;
// sql="select count(*) as cnt from tphmbrand "+strSearch;
// stmt = con.prepareStatement(sql);
// rs = stmt.executeQuery();
// if(rs.next()){
// recCount=rs.getInt("cnt");
// }
// stmt.close();
// recList=new ArrayList();
// sql="select brandid,brandname from tphmbrand "+strSearch;
// stmt=con.prepareStatement(sql);
// rs=stmt.executeQuery();
// i=0;
// while(i<pageSize*(pageNo-1)){
// rs.next();
// i++;
// }
// i=0;
// while(rs.next() && i<pageSize){
// Tphmbrand tphmbrand=new Tphmbrand();
// tphmbrand.setBrandid(rs.getLong("brandid"));
// tphmbrand.setBrandname(rs.getString("brandname"));
// recList.add(tphmbrand);
// i++;
// }
// stmt.close();
}
}
finally{
if(stmt!=null) stmt.close();
}
}
/**
* 有条件创建分页列表(含关联的表字段)
*/
public void createList1(Connection con,int pageNo,int pageSize,String strSearch) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
int i=0;
try{
if(pageNo==0 && pageSize==0){
recList=new ArrayList();
sql="select a.brandid,a.brandname from tphmbrand a where 1=1 "+strSearch;
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
i=0;
while(rs.next()){
Tphmbrand tphmbrand=new Tphmbrand();
tphmbrand.setBrandid(rs.getLong("brandid"));
tphmbrand.setBrandname(rs.getString("brandname"));
recList.add(tphmbrand);
i++;
}
stmt.close();
}else{
this.pageNo=pageNo;
this.pageSize=pageSize;
recList=new ArrayList();
sql="select a.brandid,a.brandname from tphmbrand a where 1=1 "+strSearch;
stmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery();
rs.last();
recCount=rs.getRow();
if(pageSize*(pageNo-1)==0){
rs.beforeFirst();
}else{
rs.absolute(pageSize*(pageNo-1));
}
i=0;
while(rs.next() && i<pageSize){
Tphmbrand tphmbrand=new Tphmbrand();
tphmbrand.setBrandid(rs.getLong("brandid"));
tphmbrand.setBrandname(rs.getString("brandname"));
recList.add(tphmbrand);
i++;
}
stmt.close();
// this.pageNo=pageNo;
// this.pageSize=pageSize;
// sql="select count(*) as cnt from tphmbrand a where 1=1 "+strSearch;
// stmt = con.prepareStatement(sql);
// rs = stmt.executeQuery();
// if(rs.next()){
// recCount=rs.getInt("cnt");
// }
// stmt.close();
// recList=new ArrayList();
// sql="select a.brandid,a.brandname from tphmbrand a where 1=1 "+strSearch;
// stmt=con.prepareStatement(sql);
// rs=stmt.executeQuery();
// i=0;
// while(i<pageSize*(pageNo-1)){
// rs.next();
// i++;
// }
// i=0;
// while(rs.next() && i<pageSize){
// Tphmbrand tphmbrand=new Tphmbrand();
// tphmbrand.setBrandid(rs.getLong("brandid"));
// tphmbrand.setBrandname(rs.getString("brandname"));
// recList.add(tphmbrand);
// i++;
// }
// stmt.close();
}
}
finally{
if(stmt!=null) stmt.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -