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

📄 flowertypebean.java

📁 精美的画面。完善的功能
💻 JAVA
字号:
package Flower.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.CallableStatement;
import java.util.Collection;
import java.util.Vector;
public class FlowerTypeBean 
{
  Connection con=null;
  CallableStatement cstmt=null;
  ResultSet rs=null;
  PreparedStatement pstmt=null;
  public boolean addFlowerType(Flowertype flt) throws Exception
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("insert into FlowerTYpe values(?,?)");
      pstmt.setString(1,flt.getFlowertypeid());
       pstmt.setString(2,flt.getFlowertypename());
      if(pstmt.executeUpdate()!=-1)
      {
        res=true;
      }
      else
      {
        res=false;
      }
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    return res;
  }
 

  public boolean updateFlowerType(Flowertype flt) throws Exception
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("update flowertype set flowertypename=? where flowertypeid=?");
      pstmt.setString(1,flt.getFlowertypename());
      pstmt.setString(2,flt.getFlowertypeid());
      if(pstmt.executeUpdate()!=-1)
      {
        res=true;
      }
      else
      {
        res=false;
      }
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    return res;
  }

  public boolean delFlowerType(String id)
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("delete from FlowerTYpe where FLOWERTYPEID=?");
      pstmt.setString(1,id);
      if(pstmt.executeUpdate()!=-1)
      {
        res=true;
      }
      else
      {
        res=false;
      }
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    return res;
  }

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

  public Collection findFlowerType(Flowertype flt)
  {
    Vector v=new Vector();
    try 
    {
      con=DBConnect.getConnection();
      String s=" where ";
      if(!flt.getFlowertypeid().equals(""))
        s=s+"flowertypeid like '%"+flt.getFlowertypeid()+"%' and";
      if(!flt.getFlowertypename().equals(""))
        s=s+"flowertypename like '%"+flt.getFlowertypename()+"%' and";
      if(s.equals(" where "))
        s="";
      else
        s=s.substring(0,s.lastIndexOf(" "));
      pstmt=con.prepareStatement("select * from flowertype"+s+"");
      rs=pstmt.executeQuery();
      while(rs.next())
      {
        Flowertype ft=new Flowertype();
        ft.setFlowertypeid(rs.getString(1));
        ft.setFlowertypename(rs.getString(2));
        v.add(ft);
      }
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    
    return v;
  }
  
}

⌨️ 快捷键说明

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