📄 supplybean.java
字号:
package Model_Supply;
import DataBase.ConDataBase;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
public class SupplyBean
{
public SupplyBean()
{
}
public String InsertSupply(Supply sl)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call INSERTSUPPLY(?,?,?,?,?,?)}");
cmst.setString(1,sl.getSupID());
cmst.setString(2,sl.getSupName());
cmst.setString(3,sl.getAddress());
cmst.setString(4,sl.getZipCode());
cmst.setString(5,sl.getTel());
cmst.registerOutParameter(6,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(6);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public String UpdateSupply(Supply sl)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call UPDATESUPPLY(?,?,?,?,?,?)}");
cmst.setString(1,sl.getSupID());
cmst.setString(2,sl.getSupName());
cmst.setString(3,sl.getAddress());
cmst.setString(4,sl.getZipCode());
cmst.setString(5,sl.getTel());
cmst.registerOutParameter(6,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(6);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public String DeleteSupply(String supid)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call DELETESUPPLY(?,?)}");
cmst.setString(1,supid);
cmst.registerOutParameter(2,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(2);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public Collection SelectAllSupply()
{
Connection con=ConDataBase.getConnection();
ArrayList al=new ArrayList();
try{
Statement smt=con.createStatement();
ResultSet rs=smt.executeQuery("select * from Supply");
while (rs.next())
{
Supply sp=new Supply();
sp.setSupID(rs.getString(1));
sp.setSupName(rs.getString(2));
sp.setAddress(rs.getString(3));
sp.setZipCode(rs.getString(4));
sp.setTel(rs.getString(5));
al.add(sp);
}
smt.close();
con.close();
return al;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -