package chainOfResponsibility;
public class DAO implements DAO_I {
this.conn = conn;
}
public List<News> GetAllNews
(Date date
) { List<News> newsList = new ArrayList<News>(1);
java.
sql.
Date sqlDate =
new java.
sql.
Date(date.
getTime());
try {
stmt = conn.prepareStatement("SELECT title, text FROM news WHERE date = ?");
stmt.setDate(1, sqlDate);
while (rs.next()) {
newsList.add(new News(rs.getString("title"), date, rs.getString("text")));
}
System.
out.
println("ошибочка...");
}
return newsList;
}
"SELECT title, text, date FROM news ORDER BY date DESC LIMIT 1");
if (rs.next()){
return new News(rs.getString(1), rs.getDate(3), rs.getString(2));
}
return null;
}
}