public boolean updateNews(byte newsId, String field, String newInfo)
{
boolean flag=false;
conn=com.util.ConnectionUtil.getConn();
try
{
ps=conn.prepareStatement("update news_detail set "+field+"=? where newsId=? ");
//如果set后面没有一次空格就会报java.sql.SQLSyntaxErrorException: ORA-00971: 缺失 SET 关键字
ps.setString(1, newInfo);
ps.setByte(2, newsId);
int count=ps.executeUpdate();
if(count>0)
{
flag=true;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
return flag;
}
原文:http://my.oschina.net/5icode/blog/487598