Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
PreparedStatement pst= c.prepareStatement(
"SELECT books_users.id, books.title AS book, users.name AS \"user\", return_date FROM books_users " +
"INNER JOIN books ON books.id = books_users.book " +
"INNER JOIN users ON users.id = books_users.user ORDER BY return_date DESC ");
ResultSet result = pst.executeQuery();
%>
<p><a href="new.jsp">Neuen Verleih einfügen</a></p>
<table>
<tr>
<th>Buch</th>
<th>User</th>
<th>Rückgabedatum</th><th></th><th></th>
</tr>
<%
while (result.next()) {
//Date d = result.getDate("return_date");
//String style = d.before(new Date()) ? "red" : "white";
out.println("<tr>");
out.println("<td>" + result.getString("book") + "</td>");
out.println("<td>" + result.getString("user") + "</td>");
out.println("<td>" + result.getString("return_date") + "</td>");
out.println("<td><a href='modify.jsp?loan=" + result.getString("id") + "'>ÄNDERN</a></td>");
out.println("<td><a href='delete.jsp?loan=" + result.getString("id") + "'>LÖSCHEN</a></td>");
out.println("</tr>");
}
c.close();
%>
</table>
</body>
</html>