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

📄 zclbbean.java~4~

📁 代码是自己我的代码不是网上down的。是自己写的。里面有很多值得学习的知识点。还有一些javabean组件。不算自己写的JAR文件
💻 JAVA~4~
字号:
package zcgl;

import javax.swing.*;
import java.sql.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ZcLbBean extends JPanel {
    BorderLayout borderLayout1 = new BorderLayout();
    private int zlId;
    private String zlName;
    private int subId;
    private String subName;
    private Connection con=null;
    public int getZlId() {
        return zlId;
    }

    public String getZlName() {
        return zlName;
    }

    public int getSubId() {
        return subId;
    }

    public String getSubName() {
        return subName;
    }

    public void setZlId(int zlId) {
        this.zlId = zlId;
    }

    public void setZlName(String zlName) {
        this.zlName = zlName;
    }

    public void setSubId(int subId) {
        this.subId = subId;
    }

    public void setSubName(String subName) {
        this.subName = subName;
    }
    public boolean insert(){
        con = new DBConn().getConnection();
       PreparedStatement pstm = null;
       try {
           pstm = con.prepareStatement("insert into CATEGORY values(?,?,?,?)");
          // if(pstm.getResultSet().next())
          // {
           pstm.setInt(1,zlId);
           pstm.setString(2,zlName);
           pstm.setInt(3,subId);
           pstm.setString(4,subName);
           pstm.executeUpdate();
           return true;

         //  }
         //  else
          // {
         //     JOptionPane.showMessageDialog(null,"此信息已经存在!");
         //      return false;
         //  }


       } catch (Exception ex) {
           return false;
       }

   }
   public boolean del(){
       con = new DBConn().getConnection();
       PreparedStatement pstm = null;
       try {
           pstm = con.prepareStatement("delete from CATEGORY where cateid=?");
           pstm.setInt(1,zlId);
           pstm.executeUpdate();
           return true;
       } catch (Exception ex) {
           return false;
       }

   }
   public boolean modify(){
        con = new DBConn().getConnection();
      PreparedStatement pstm = null;
      int Id=zlId;
      try {
          pstm = con.prepareStatement("update CATEGORY set cateid=?,catename=?,subcateid=?,subcatename=? where cateid="+Id);
          pstm.setInt(1,zlId);
          pstm.setString(2,zlName);
          pstm.setInt(3,subId);
          pstm.setString(4,subName);
          pstm.executeUpdate();
          return true;
      } catch (Exception ex) {
          return false;
      }

   }
   public boolean isNull() {

     con = new DBConn().getConnection();
     Statement smt = null;
     try {
         smt = con.createStatement();
         ResultSet rs=smt.executeQuery("select * from CATEGORY where cateid="+zlId);
         if(rs.next())
             return false;


     } catch (SQLException ex) {
     }

     return true;
 }

}

}

⌨️ 快捷键说明

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