* @param id ID of news article to fetch
* @return Information associated to ID wrapped into a bean
**/
private NewsBean getNewsById(String id)
throws ServletException {
NewsBean temp=new NewsBean();
synchronized(this) {
try {
int num_id=Integer.parseInt(id);
//select specific new article
PreparedStatement stmt=DBInterface.doQuery("SELECT * FROM news WHERE id=?");
stmt.setInt(1,num_id);
ResultSet result=stmt.executeQuery();
if (result.next()) {
temp.setId(result.getInt("id"));
temp.setAuthor(result.getInt("author"));
temp.setDate(result.getTimestamp("date"));
temp.setTitle(result.getString("title"));
temp.setContent(GlobalHelpers.nl2br(result.getString("content")));
}
result.close();
stmt.close();
DBInterface.close();