Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <-------------------------Java kode ------------------------------>
- public static Comment getCommentById(long Comment_id) {
- Comment result = null;
- Connection myConn = null;
- try {
- myConn = JDBCConnectionFactory.getNewConnection();
- String sql = "SELECT * FROM Comment WHERE comment_id = ?";
- PreparedStatement prep = myConn.prepareStatement(sql);
- prep.setLong(1, Comment_id);
- ResultSet res = prep.executeQuery();
- result = createCommentFromResultSet(res);
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- JDBCConnectionFactory.closeConnection(myConn);
- }
- return result;
- }
- <------------------- Her kommer vores JSP-Hiphop forum ----------------------------------------->
- <%
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/u201507985",
- "u201507985", "Butm51uR", "com.mysql.jdbc.Driver");
- ArrayList<Post> posts = PostDao.getPostsByGenre("Hiphop");
- ArrayList<Comment> newComments = CommentDAO.getAllComments();
- for (Post post : posts) {
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement