📄 tchannellistimpl.java
字号:
package com.sxit.pim.channel;
import com.sxit.common.ListImpl;
import java.util.*;
import java.sql.*;
/**
* <p>类名: TchannelListImpl</p>
* <p>功能: channel</p>
* <p>公司: 深讯信科</p>
* <p>版本: 1.0</p>
* @程序 sxit
* @日期 2005-12-14
* @修改纪录
*/
public class TchannelListImpl extends ListImpl
{
public TchannelListImpl()
{
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 id,cp_id,channel_name,corporationid from tchannel "+strSearch;
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
i=0;
while(rs.next()){
Tchannel tchannel=new Tchannel();
tchannel.setId(rs.getInt("id"));
tchannel.setCp_id(rs.getInt("cp_id"));
tchannel.setChannel_name(rs.getString("channel_name"));
tchannel.setCorporationid(rs.getInt("corporationid"));
recList.add(tchannel);
i++;
}
stmt.close();
}else{
this.pageNo=pageNo;
this.pageSize=pageSize;
recList=new ArrayList();
sql="select id,cp_id,channel_name,corporationid from tchannel "+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){
Tchannel tchannel=new Tchannel();
tchannel.setId(rs.getInt("id"));
tchannel.setCp_id(rs.getInt("cp_id"));
tchannel.setChannel_name(rs.getString("channel_name"));
tchannel.setCorporationid(rs.getInt("corporationid"));
recList.add(tchannel);
i++;
}
stmt.close();
// this.pageNo=pageNo;
// this.pageSize=pageSize;
// strSearch=" where 1=1 "+strSearch;
// sql="select count(*) as cnt from tchannel "+strSearch;
// stmt = con.prepareStatement(sql);
// rs = stmt.executeQuery();
// if(rs.next()){
// recCount=rs.getInt("cnt");
// }
// stmt.close();
// recList=new ArrayList();
// sql="select id,cp_id,channel_name,corporationid from tchannel "+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){
// Tchannel tchannel=new Tchannel();
// tchannel.setId(rs.getInt("id"));
// tchannel.setCp_id(rs.getInt("cp_id"));
// tchannel.setChannel_name(rs.getString("channel_name"));
// tchannel.setCorporationid(rs.getInt("corporationid"));
// recList.add(tchannel);
// 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();
System.out.println("ffffffffffffffffffffffff");
sql="select a.cp_id,a.channel_name,a.corporationid,a.id,b.cp_name from tchannel a,tcp b where 1=1 and a.cp_id=b.id(+) "+strSearch;
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
i=0;
while(rs.next()){
Tchannel tchannel=new Tchannel();
tchannel.setId(rs.getInt("id"));
System.out.println("gggggggggggggggggggggg");
tchannel.setCp_id(rs.getInt("cp_id"));
tchannel.setChannel_name(rs.getString("channel_name"));
tchannel.setCorporationid(rs.getLong("corporationid"));
tchannel.setCpname(rs.getString("cp_name"));
recList.add(tchannel);
i++;
}
stmt.close();
}else{
this.pageNo=pageNo;
this.pageSize=pageSize;
recList=new ArrayList();
sql="select a.cp_id,a.channel_name,a.corporationid,a.id,b.cp_name from tchannel a,tcp b where 1=1 and a.cp_id=b.id "+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){
Tchannel tchannel=new Tchannel();
tchannel.setId(rs.getInt("id"));
tchannel.setCp_id(rs.getInt("cp_id"));
tchannel.setChannel_name(rs.getString("channel_name"));
tchannel.setCorporationid(rs.getLong("corporationid"));
tchannel.setCpname(rs.getString("cp_name"));
recList.add(tchannel);
i++;
}
stmt.close();
// this.pageNo=pageNo;
// this.pageSize=pageSize;
// sql="select count(*) as cnt from tchannel a,tcp b where 1=1 and a.id=b.id(+) "+strSearch;
// stmt = con.prepareStatement(sql);
// rs = stmt.executeQuery();
// if(rs.next()){
// recCount=rs.getInt("cnt");
// }
// stmt.close();
// recList=new ArrayList();
// sql="select a.cp_id,a.channel_name,a.corporationid,a.id,b.name from tchannel a,tcp b where 1=1 and a.id=b.id(+) "+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){
// Tchannel tchannel=new Tchannel();
// tchannel.setId(rs.getInt("id"));
// tchannel.setCp_id(rs.getInt("cp_id"));
// tchannel.setChannel_name(rs.getString("channel_name"));
// tchannel.setCorporationid(rs.getInt("corporationid"));
// tchannel.setName(rs.getString("name"));
// recList.add(tchannel);
// i++;
// }
// stmt.close();
}
}
finally{
if(stmt!=null) stmt.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -