⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 consumerloginbean.java

📁 精美的画面。完善的功能
💻 JAVA
字号:
package Flower.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class ConsumerLoginBean 
{
  Connection con=null;
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  public boolean addCusLogin(Consumerlogin cuslog) throws Exception
  {
    boolean res=false;
    try 
    {
        con=DBConnect.getConnection();
        pstmt=con.prepareStatement("insert into ConsumerLogin values(?,?,?)");
        pstmt.setString(1,cuslog.getConsumerid());
        pstmt.setString(2,cuslog.getConsumername());
        pstmt.setString(3,cuslog.getConsumerpassword());
        pstmt.executeUpdate();
        pstmt.close();
        con.close();
        res=true;
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    } 
     
    return res;
  }

  public boolean delCusLogin(String id)
  {
    boolean res=false;
    try
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("delete from ConsumerLogin where ConsumerID=?");
      pstmt.setString(1,id);
      pstmt.executeUpdate();
      pstmt.close();
      con.close();
      res=true;
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
    }
    return res;
  }

  public boolean updateCuslogin(Consumerlogin cuslog) throws Exception
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("update ConsumerLogin set ConsumerName=?,ConsumerPassword=? where ConsumerID=?");
      pstmt.setString(1,cuslog.getConsumername());
      pstmt.setString(2,cuslog.getConsumerpassword());
      pstmt.setString(3,cuslog.getConsumerid());
      pstmt.executeUpdate();
      pstmt.close();
      con.close();
      res=true;
    }
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    return res;
  }

  public boolean getID(String id)
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("select * from Consumerlogin where ConsumerID=?");
      pstmt.setString(1,id);
      rs=pstmt.executeQuery();
      if(rs.next())
      {
        res=true;
      }
      else
      {
        res=false;
      }
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
      System.out.print(ex.getMessage());
    }
    
    return res;
  }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -