public List<SuggestCommandView> getSuggests()
{
Connection connection = null;
try {
List<SuggestCommandView>list = new ArrayList<SuggestCommandView>();
final String sql = "select * from APP_SUGGEST order by UPDATETIME desc,CREATETIME desc";
connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement(sql);
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
SuggestCommandView sug = new SuggestCommandView();
sug.setCreateTime(resultSet.getTimestamp("CREATETIME"));
sug.setMark(resultSet.getString("MARK"));
sug.setSugCode(resultSet.getString("SUGCODE"));
sug.setSugcontent(resultSet.getString("sugcontent"));
list.add(sug);
}
return list;
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
};
public void createSuggest(SuggestCommandVo vo)
{
Connection connection = null;
Statement stm = null;
try {
connection = dataSource.getConnection();
stm = connection.createStatement();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间
String str = df.format(now);
final String sql = " insert into TBL_SUGGEST values(SUGGEST_SEQ.NEXTVAL,'"+vo.getSugCode()+"',to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),'"+vo.getMark()+"','"+vo.getSugcontent()+"')";
stm.execute(sql);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
stm.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
public void updateSuggest(SuggestCommandVo vo)
{
Connection connection = null;
Statement stm = null;
try {
connection = dataSource.getConnection();
stm = connection.createStatement();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间
String str = df.format(now);
final String sql = " update TBL_SUGGEST set SUGCODE = '"+vo.getSugCode()+"',UPDATETIME = to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),MARK='"+vo.getMark()+"',SUGCONTENT ='"+vo.getSugcontent()+"'";
stm.execute(sql);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
stm.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
{
Connection connection = null;
try {
List<SuggestCommandView>list = new ArrayList<SuggestCommandView>();
final String sql = "select * from APP_SUGGEST order by UPDATETIME desc,CREATETIME desc";
connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement(sql);
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
SuggestCommandView sug = new SuggestCommandView();
sug.setCreateTime(resultSet.getTimestamp("CREATETIME"));
sug.setMark(resultSet.getString("MARK"));
sug.setSugCode(resultSet.getString("SUGCODE"));
sug.setSugcontent(resultSet.getString("sugcontent"));
list.add(sug);
}
return list;
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
};
public void createSuggest(SuggestCommandVo vo)
{
Connection connection = null;
Statement stm = null;
try {
connection = dataSource.getConnection();
stm = connection.createStatement();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间
String str = df.format(now);
final String sql = " insert into TBL_SUGGEST values(SUGGEST_SEQ.NEXTVAL,'"+vo.getSugCode()+"',to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),'"+vo.getMark()+"','"+vo.getSugcontent()+"')";
stm.execute(sql);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
stm.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
public void updateSuggest(SuggestCommandVo vo)
{
Connection connection = null;
Statement stm = null;
try {
connection = dataSource.getConnection();
stm = connection.createStatement();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间
String str = df.format(now);
final String sql = " update TBL_SUGGEST set SUGCODE = '"+vo.getSugCode()+"',UPDATETIME = to_timestamp('"+ str +"','yyyy-mm-dd hh24:mi:ss'),MARK='"+vo.getMark()+"',SUGCONTENT ='"+vo.getSugcontent()+"'";
stm.execute(sql);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
stm.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}