import ;
import ;
import ;
import ;
import ;
public class SqlOperate {
//增加
public static boolean add(Nobel no){
PreparedStatement pstmt = null;
int x = 0;
Connection conn = ();
String sql = "insert into nobel (id,author,subject,works,ttime,country) values (?,?,?,?,?,?)";
try {
pstmt = (sql);
(1, ());
(2, ());
(3, ());
(4, ());
(5, ());
(6, ());
x = ();
} catch (SQLException e) {
();
} finally{
try {
if(pstmt!=null)
();
if(conn!=null)
();
} catch (SQLException e) {
();
}
}
if(x==1){
return true;
}else {
return false;
}
}
//删除
public static boolean del(int id){
Statement stmt = null;
int x = 0;
Connection conn = ();
String sql = "delete from nobel where id="+id;
try {
stmt = ();
x = (sql);
} catch (SQLException e) {
();
} finally{
try {
if(stmt!=null)
();
if(conn!=null)
();
} catch (SQLException e) {
对数据库操作的案例 来自淘豆网m.daumloan.com转载请标明出处.