?? stayinhpservice.java
字號:
package com.tsinghuait.st0717.hospitalsystem.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.tsinghuait.st0717.hospitalsystem.dao.SQLConnection;
import com.tsinghuait.st0717.hospitalsystem.dto.StayInHp;
public class StayInHpService{
// 查詢
public ResultSet selectStay(String sql){
ResultSet rs=null;
rs=new SQLConnection().executeQuery(sql);
return rs;
}
//遍歷住院表
public ArrayList selectRowsStay(String sql) throws SQLException{
ArrayList<StayInHp> arr=null;
ResultSet rs=new SQLConnection().executeQuery(sql);
if(rs!=null)
{
arr=new ArrayList<StayInHp>();
try
{
int i=0;
while(rs.next()&&rs!=null)
{
StayInHp dto=new StayInHp();
dto.setId(rs.getInt("id"));
dto.setPatientId(rs.getInt("patientId"));
dto.setBedId(rs.getInt("bedId"));
dto.setDays(rs.getInt("days"));
arr.add(dto);
i++;
}
}catch(Exception e)
{
System.out.println("對住院表的操作有誤!");
e.printStackTrace();
}
}
return arr;
}
//對數據庫操作
public int execteUpdate(String sql){
int num=0;
num=new SQLConnection().executeUpdate(sql);
return num;
}
//刪除住院表信息
public int deleteById(int oid)
{
return new SQLConnection().executeUpdate("delete from patient where id"+oid);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -