?? computerdao.java~10~
字號:
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 {
public ComputerDAO() {
}
public ArrayList getNoUsedComputerList() {
ArrayList list = new ArrayList();
Connection dbConnection = null;
PreparedStatement pStatement = null;
ResultSet res = null;
try {
dbConnection = ConnectionManager.getConnction();
// 查詢數據SQL語句
String strSql = "select * from computer where onuse!= '1'";
if (dbConnection != null) {
System.out.println(dbConnection != null);
}
//查詢操作
pStatement = dbConnection.prepareStatement(strSql);
res = pStatement.executeQuery();
while (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 {
ConnectionManager.closeResultSet(res);
ConnectionManager.closeStatement(pStatement);
ConnectionManager.closeConnection(dbConnection);
} //finally
return list;
}
public void recordOnUse(Computer computer) {
Connection dbConnection = null;
PreparedStatement pStatement = null;
try {
String strSql =
"update computer set OnUse =1 where id =(?) ; ";
pStatement = dbConnection.prepareStatement(strSql);
pStatement.setString(1, computer.getId());
pStatement.executeUpdate();
}
catch (SQLException sqlE) {
sqlE.printStackTrace();
}
finally {
ConnectionManager.closeStatement(pStatement);
ConnectionManager.closeConnection(dbConnection);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -