📄 handle.java
字号:
package b;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
public class Handle {
Con_db con_db;
Statement sta;
ResultSet st;
public Handle() {
con_db = new Con_db();
}
public boolean voInsert(IdentifyVo iv) {
boolean w = false;
try {
String v_name = iv.getName();
String sql = "insert into qin values ('" +v_name + "')";
sta = con_db.con.createStatement();
sta.executeUpdate(sql);
w = true;
} catch (Exception e) {
e.printStackTrace();
}
return w;
}
public ArrayList voSelect() {
ArrayList a=new ArrayList();
try {
String sql = "select * from qin";
sta = con_db.con.createStatement();
sta.executeQuery(sql);
st = sta.getResultSet();
while (st.next()) {
IdentifyVo iv=new IdentifyVo();
iv.setId(Integer.parseInt(st.getString("id")));
iv.setName(st.getString("name"));
a.add(iv);
}
} catch (Exception e) {
e.printStackTrace();
}
return a;
}
public IdentifyVo selectOne(int id){
IdentifyVo iv=new IdentifyVo();
try {
String sql="select * from qin where id="+id;
sta = con_db.con.createStatement();
sta.executeQuery(sql);
st=sta.getResultSet();
while(st.next()){
iv.setId(Integer.parseInt(st.getString("id")));
iv.setName(st.getString("name"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return iv;
}
public boolean voDelete(int id){
boolean w=false;
try {
sta=con_db.con.createStatement();
String sql="delete from qin where id="+id;
sta.executeUpdate(sql);
w=true;
} catch (SQLException e) {
e.printStackTrace();
}
return w;
}
// public void voDeleteAll(Object []deleteall){
// try {
// sta=con_db.con.createStatement();
// for(int i=0;i<deleteall.length;i++){
// String sql="delete from reg where reg_id="+deleteall[i];
// sta.executeUpdate(sql);
// }
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
public boolean voModify(IdentifyVo iv){
boolean w=false;
try {
sta=con_db.con.createStatement();
String sql="update qin set name='"+iv.getName()+"' where id="+iv.getId();
sta.executeUpdate(sql);
w=true;
} catch (SQLException e) {
e.printStackTrace();
}
return w;
}
// public static void main(String[] args){
// Handle h=new Handle();
// h.voDelete(27);
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -