private Connection conn = null;
private PreparedStatement ps = null;
private ResultSet rs = null;
/**
* 添加方法
*/
public void insert(NoteMms record) {
// 主键编号
int insertkey = 0;
// 查询序列
String sequence = "select S_TBL_NOTEMMS.nextval from dual";
// 插入语句
String sql = "insert into TBL_NOTEMMS (ID, SENDPHONE, RECEIVEPHONE, CREATETIME) values (?,?,?,?)";
try {
conn = Conn.getConn();
ps = conn.prepareStatement(sequence);
rs = ps.executeQuery();
rs.next();
insertkey = rs.getInt(1);
ps = conn.prepareStatement(sql);
ps.setInt(1, insertkey);
ps.setString(2, record.getSendphone());
ps.setString(3, record.getReceivephone());
ps.setDate(4, new java.sql.Date(record.getCreatetime().getTime()));
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
rs.close();
ps.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}