📄 consumerinfobean.java
字号:
package Flower.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
public class ConsumerInfoBean
{
Connection con=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
public boolean addConInfo(Consumerinfo ConsInfo) throws Exception
{
boolean res=false;
try
{
con=DBConnect.getConnection();
pstmt=con.prepareStatement("insert into ConsumerInfo values(?,?,?,?,?,?,?,?)");
pstmt.setString(1,ConsInfo.getConsumerid());
pstmt.setString(2,ConsInfo.getRealname());
pstmt.setString(3,ConsInfo.getConsumersex());
pstmt.setString(4,ConsInfo.getIdentitycard());
pstmt.setString(5,ConsInfo.getAddress());
pstmt.setString(6,ConsInfo.getZipcode());
pstmt.setString(7,ConsInfo.getEmail());
pstmt.setString(8,ConsInfo.getTel());
pstmt.executeUpdate();
pstmt.close();
con.close();
res=true;
}
catch (Exception ex)
{
ex.printStackTrace();
}
return res;
}
public boolean delConInfo(String id)
{
boolean res=false;
try
{
con=DBConnect.getConnection();
pstmt=con.prepareStatement("delete from ConsumerInfo where ConsumerID=?");
pstmt.setString(1,id);
pstmt.executeUpdate();
pstmt.close();
con.close();
res=true;
}
catch (Exception ex)
{
ex.printStackTrace();
}
return res;
}
public boolean updateConInfo(Consumerinfo consInfo) throws Exception
{
boolean res=false;
try
{
con=DBConnect.getConnection();
pstmt=con.prepareStatement("update ConsumerInfo set RealName=?,ConsumerSex=?,Identitycard=?,address=?,zipcode=?,email=?,tel=? where ConsumerID=?");
pstmt.setString(1,consInfo.getRealname());
pstmt.setString(2,consInfo.getConsumersex());
pstmt.setString(3,consInfo.getIdentitycard());
pstmt.setString(4,consInfo.getAddress());
pstmt.setString(5,consInfo.getZipcode());
pstmt.setString(6,consInfo.getEmail());
pstmt.setString(7,consInfo.getTel());
pstmt.setString(8,consInfo.getConsumerid());
pstmt.executeUpdate();
pstmt.close();
con.close();
res=true;
}
catch (Exception ex)
{
ex.printStackTrace();
}
return res;
}
public boolean getConID(String id)
{
boolean res=false;
try
{
con=DBConnect.getConnection();
pstmt=con.prepareStatement("select * form ConsumerInfo where ConsumerID=?");
pstmt.setString(1,id);
rs=pstmt.executeQuery();
if(rs.next())
{
res=true;
}
else
{
res=false;
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
return res;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -