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

📄 computerdao.java~9~

📁 ACCP课程中的商业程序网吧管理系统
💻 JAVA~9~
字号:
package com.jbaptech.accp.netbar.server.dao;

import com.jbaptech.accp.netbar.server.entity.Card;
import java.sql.*;
import java.util.ArrayList;
import com.jbaptech.accp.netbar.server.entity.Computer;

public class ComputerDAO extends BaseDAO{
  public ComputerDAO(){
  }

  public ArrayList getNoUsedComputerList() {

   ArrayList list = new ArrayList();
   try {
     this.dbConnection = this.getConnction();
     // 查询数据SQL语句
     this.strSql = "select * from computer where onuse!= '1'";
     if(dbConnection!=null){
       System.out.println(dbConnection!=null);
     }

     //查询操作
     this.pStatement = this.dbConnection.prepareStatement(this.strSql);
     this.res = this.pStatement.executeQuery();
     while (this.res.next()) {
       Computer computer = new Computer();
       computer.setId(res.getString("id"));
       computer.setOnUse(res.getString("onuse"));
       computer.setNotes(res.getString("notes"));
       list.add(computer);
     }
   }
   catch (SQLException sqlE) {
     sqlE.printStackTrace();
   }
   finally {
       this.clearDao();
   } //finally

   return list;
 }

 public void recordOnUse(Computer computer) {
   try {
     this.strSql =
         "update computer set OnUse =1 where id =(?) ; ";

     this.pStatement = this.dbConnection.prepareStatement(this.strSql);
     this.pStatement.setString(1, computer.getId());
     this.pStatement.executeUpdate();
   }
   catch (SQLException sqlE) {
     sqlE.printStackTrace();
   }
   finally {
     this.clearDao();
   } //finally
 }

}

⌨️ 快捷键说明

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