Connection connection = dataSource.getConnection();
PreparedStatement ppsm = connection.prepareStatement(sql);
ResultSet blogrs = ppsm.executeQuery();
while (blogrs.next()) {
EntryImpl be = new EntryImpl();
be.setId(blogrs.getLong("id"));
be.setBlogText(blogrs.getString("blogText"));
be.setPublishDate(blogrs.getDate("publishDate"));
be.setTitle(blogrs.getString("title"));
be.setUpdatedDate(blogrs.getDate("updatedDate"));
// find the author email address
String author_email = blogrs.getString("AUTHOR_EMAIL");
String author_sql = "SELECT * FROM Author a WHERE a.email ='"
+ author_email + "'";
List<AuthorImpl> authors = findAuthors(author_sql);
// there should be just one entry, as email is the primary key
// for the Author table
if (authors.size() != 1)
throw new IllegalArgumentException(
"We got more than one author with the same email address. This is wrong");
else
be.setAuthor(authors.get(0));
blogEntryList.add(be);
}
ppsm.close();
connection.close();
} catch (Exception e) {