package com.addresslist.madedata;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import com.addresslist.bean.MyDb;
import com.addresslist.madedata.inter.MadeAddressDAO;
import com.addresslist.pagination.PagInation;
import java.sql.Connection;
public class ImpleteMadeAddressDAO implements MadeAddressDAO{
private int pageNum = 0;// 总页数
private int size = 0;// 总行数
private int pageId = 1;
public ArrayList SelectAllAddress(int pageId ,String where) throws Exception {
String sql = "select * from message where relationship = '"+ where+"'";
Connection con = null;
Statement sta = null;
ResultSet rs = null;
ArrayList address = null;
PagInation fenye = new PagInation();
// 执行查询语句
try {
con = MyDb.connection("tongxunlu");
sta = MyDb.Getsta(con);
rs = MyDb.query(sql,sta);
address = fenye.selectAddress(pageId, rs);
pageNum = fenye.getPageNum();
this.pageId = fenye.getPageId();
size = fenye.getSize();
} catch (Exception e) {
// TODO: handle exception
System.out.println("as");
} finally {
MyDb.close(rs, sta, con);
}
return address;
}
public boolean AlterM(String sql){
Connection con = null;
Statement sta = null;
try {
con = MyDb.connection("tongxunlu");
sta = MyDb.Getsta(con);
sta.executeUpdate(sql);
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
MyDb.close(sta, con);
}
return false;
}
// 第几页
public int getPageId() {
return pageId;
}
// 总页数
public int getPageNum() {
return pageNum;
}
// 总行数
public int getSize() {
return size;
}
}
评论0
最新资源