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; }
时间: 2024-10-13 16:05:29