JAVA日报

excel(itemdao)

/*UserID,UserName,sex,idNumber,Phone,User;*/
package dao;
import util.*;
import java.sql.*;

import bean.*;
import util.*;
public class ItemDao {
public static boolean add(item t) throws ClassNotFoundException{
String sql = "insert into news values('"+t.getContent()+"','"+t.getChannelName()+"','"+t.getTitle()+"')";
Statement stat=null;
Connection conn=null;
int act=0;
conn = db.getConn();
try {
stat=conn.createStatement();
act=stat.executeUpdate(sql);
}catch(Exception e) {
e.printStackTrace();
}finally {
db.close(stat,conn);
}
if(act>0) {
return true;
}else {
return false;
}
}

public static void main(String[] args) throws Exception {
// System.out.println(ItemDao.getAlldatainfos("10"));
// conn.close();
}
}
posted @ 2021-12-10 21:11  我的未来姓栗山  阅读(29)  评论(0编辑  收藏  举报