📄 tocompeditselectdao.java
字号:
package com.isoftstone.banktearm1.dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import com.isoftstone.banktearm1.db.DB;
import com.isoftstone.banktearm1.vo.BankTeam1CompVoAll;
public class ToCompEditSelectDao extends DB {
public ArrayList getAllSelect()throws SQLException, ClassNotFoundException{
ArrayList list = new ArrayList();
Connection cn=this.getConnection();
Statement stmt=cn.createStatement();
String sql="select comp.NumberID,comp.ComputerType,comp.CPU,comp.Memory,comp.Harddisk,comp.IPAddress,comp.MACAddress,comp.UserName,unit.UnitName+':'+dep.DepartmentName,comp.BuyTime,comp.UseTime"+
" from dep,comp,unit"+
" where comp.NumberID and mid(cstr(comp.NumberID),1,4)=cstr(dep.DepartmentID) and mid(cstr(comp.NumberID),1,2)=cstr(unit.UnitID)";
//System.out.println(sql);
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
BankTeam1CompVoAll vo=new BankTeam1CompVoAll();
vo.setNumberId(rs.getInt("NumberID"));
vo.setComputerType(rs.getString("ComputerType"));
vo.setCpu(rs.getString("CPU"));
vo.setMemory(rs.getString("Memory"));
vo.setHarddisk(rs.getString("Harddisk"));
vo.setIpAddress(rs.getString("IPAddress"));
vo.setMacAddress(rs.getString("MACAddress"));
vo.setUserName(rs.getString("UserName"));
vo.setExpr(rs.getString("Expr1008"));
vo.setBuyTime(rs.getDate("BuyTime"));
vo.setUseTime(rs.getDate("UseTime"));
list.add(vo);
}
this.closs(rs, stmt, cn);
return list;
}
public ArrayList getList(String str) throws SQLException, ClassNotFoundException
{
ArrayList list=new ArrayList();
ResultSet rs=null;
Statement stmt=null;
Connection cn=null;
String sql=str;
cn=this.getConnection();
stmt=cn.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next()){
BankTeam1CompVoAll vo=new BankTeam1CompVoAll();
vo.setNumberId(rs.getInt("NumberID"));
vo.setComputerType(rs.getString("ComputerType"));
vo.setCpu(rs.getString("CPU"));
vo.setMemory(rs.getString("Memory"));
vo.setHarddisk(rs.getString("Harddisk"));
vo.setIpAddress(rs.getString("IPAddress"));
vo.setMacAddress(rs.getString("MACAddress"));
vo.setUserName(rs.getString("UserName"));
vo.setExpr(rs.getString("Expr1008"));
vo.setBuyTime(rs.getDate("BuyTime"));
vo.setUseTime(rs.getDate("UseTime"));
list.add(vo);
}
this.closs(rs, stmt, cn);
return list;
}
public void getUpdate(String str)throws SQLException, ClassNotFoundException{
Connection cn=this.getConnection();
Statement stmt=cn.createStatement();
String sql=str;
stmt.executeUpdate(sql);
this.closs(stmt,cn);
}
public void delete(int i) throws SQLException, ClassNotFoundException{
Connection con=this.getConnection();
Statement stmt=con.createStatement();
String sql="delete * from comp where NumberID="+i;
stmt.executeUpdate(sql);
this.closs(stmt,con);
}
public void getDelete(String []str) throws NumberFormatException, SQLException, ClassNotFoundException{
for(int i=0;i<str.length;i++)
this.delete(Integer.parseInt(str[i]));
}
public ArrayList getListXx(String str)throws SQLException, ClassNotFoundException{
ArrayList list = new ArrayList();
Connection cn=this.getConnection();
Statement stmt=cn.createStatement();
String sql=str;
// System.out.println(sql);
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
BankTeam1CompVoAll vo=new BankTeam1CompVoAll();
vo.setNumberId(rs.getInt("NumberID"));
vo.setComputerType(rs.getString("ComputerType"));
vo.setCpu(rs.getString("CPU"));
vo.setMemory(rs.getString("Memory"));
vo.setHarddisk(rs.getString("Harddisk"));
vo.setIpAddress(rs.getString("IPAddress"));
vo.setMacAddress(rs.getString("MACAddress"));
vo.setUserName(rs.getString("UserName"));
vo.setExpr(rs.getString("Expr1008"));
vo.setBuyTime(rs.getDate("BuyTime"));
vo.setUseTime(rs.getDate("UseTime"));
vo.setOs(rs.getString("OS"));
vo.setMend(rs.getString("Mend"));
vo.setAntiVirus(rs.getString("AntiVirus"));
vo.setHouseId(rs.getString("HouseID"));
vo.setDutyPeople(rs.getString("DutyPeople"));
vo.setUse(rs.getString("Use"));
vo.setWhichUse(rs.getString("WhichUse"));
list.add(vo);
}
this.closs(rs, stmt, cn);
return list;
}
public static void main(String age[]){
// ToCompEditSelectDao dao=new ToCompEditSelectDao();
// try{
// int i=100010;
// dao.delete(i);
// }
// catch (Exception e) {
// System.out.println(e.getMessage());
// }
// ToCompEditSelectDao dao=new ToCompEditSelectDao();
//
// ArrayList list=new ArrayList();
//
// try{
// list=dao.getAllSelect();
// if(list!=null)
// {
// Iterator it=list.iterator();
// while(it.hasNext()){
// BankTeam1CompVoAll vo=(BankTeam1CompVoAll)it.next();
// System.out.println(vo.getNumberId());
// System.out.println( vo.getCpu());
//
// }
//
//
// }
// }
// catch (Exception e) {
// System.out.println(e.getMessage());
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -