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

📄 service.java

📁 车辆管理系统
💻 JAVA
字号:
package DB;
import java.sql.*;

public class Service {
    Connection con = new Db().getCon();


     public String add1(String CarId,String Car,String CarType,String CarPlace,String CarColor,String CarPrice) throws Exception{
         String str = "失败";
         Statement stmt=con.createStatement() ;
         String sql = "insert into car values("+CarId+",'"+Car+"','"+CarType+"','"+CarPlace+"','"+CarColor+"',"+CarPrice+")";
         int i=stmt.executeUpdate(sql);
         if(i>0){
             str="成功";
         }
         stmt.close();
         return str;

     }
     public void add1(){
         try {
             Statement stmt = con.createStatement();
             int count = stmt.executeUpdate("insert ");
         } catch (SQLException ex) {
         }
     }

     public String add2(String CarId,String Year) throws Exception{
        String str = "失败";
        Statement stmt=con.createStatement() ;
        String sql = "UPDATE car SET Year='"+Year+"' where CarId="+CarId;
        int i=stmt.executeUpdate(sql);
        if(i>0){
            str="成功";
        }
        stmt.close();
        return str;

    }
    public void add2(){
        try {
            Statement stmt = con.createStatement();
            int count = stmt.executeUpdate("insert ");
        } catch (SQLException ex) {
        }
    }


    public String add3(String CarId,String CarName,String Pay,String Day,String Company) throws Exception{
            String str = "失败";
            Statement stmt=con.createStatement() ;
            String sql = "insert into safe values("+CarId+",'"+CarName+"','"+Pay+"','"+Day+"','"+Company+"')";
            int i=stmt.executeUpdate(sql);
            if(i>0){
                str="成功";
            }
            stmt.close();
            return str;

        }
        public void add3(){
            try {
                Statement stmt = con.createStatement();
                int count = stmt.executeUpdate("insert ");
            } catch (SQLException ex) {
            }
     }


     public String Updata(String CarId,String Car,String CarType,String CarPlace,String CarColor,String CarPrice) throws Exception{
        String str = "失败";
        Statement stmt=con.createStatement() ;
        String sql = "UPDATE car SET Car='"+Car+"',CarType='"+CarType+"',CarPlace='"+CarPlace+"',CarColor='"+CarColor+"',CarPrice="+CarPrice+" where CarId="+CarId;
        int i=stmt.executeUpdate(sql);
        if(i>0){
            str="成功";
        }
        stmt.close();
        return str;

    }
    public void Updata(){
        try {
            Statement stmt = con.createStatement();
            int count = stmt.executeUpdate("update");
        } catch (SQLException ex) {
        }
    }


   /* public String Find(String CarId) throws Exception{
          String str = "失败";
          Statement stmt=con.createStatement() ;
          String sql = "SELECT * FROM car where CarId="+"'"+CarId+"'";

          int i=stmt.executeUpdate(sql);
          if(i>0){
              str="成功";
          }
          stmt.close();
          return str;
      }
      public void Find(){
          try {
              Statement stmt = con.createStatement();
              int count = stmt.executeUpdate("select");
          } catch (SQLException ex) {
          }
    }*/

    public String Delete(String CarId) throws Exception{
       String str = "对不起,没有这个车牌号!";
       Statement stmt=con.createStatement() ;
       String sql = "delete from car where CarId="+"'"+CarId+"'";

       int i=stmt.executeUpdate(sql);
       if(i>0){
           str="信息已删除!";
       }
       stmt.close();
       return str;
   }
   public void Delete(){
       try {
           Statement stmt = con.createStatement();
           int count = stmt.executeUpdate("delete");
       } catch (SQLException ex) {
       }
 }


}

⌨️ 快捷键说明

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