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
63
64
65
66
67
68
<%@ 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" %>
<!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 id, title, year FROM books");
ResultSet result = pst.executeQuery();
%>
<p><a href="new.jsp">Neues Buch einfügen</a></p>
<table>
<tr>
<th>Title</th>
<th>Year</th><th></th><th></th>
</tr>
<%
while (result.next()) {
//Two ways
/*String line = "<tr><td style='width:200px'>"+
"$title</td><td style='width:100px'>$year</td><td>" +
"<a href='delete.jsp?book=$id'>LÖSCHEN</a></td></tr>";
// delete this because of UUID-->line = line.replace("$id", result.getString("id"));
line = line.replace("$title", result.getString("title"));
line = line.replace("$year", result.getString("year"));
out.println(line);*/
out.println("<tr>");
// delete this because of UUID --> out.println("<td style='font-weight:bold'>" + result.getString("id") + "</td>");
out.println("<td>" + result.getString("title") + "</td>");
out.println("<td>" + result.getString("year") + "</td>");
out.println("<td><a href='modify.jsp?book=" + result.getString("id") + "'>ÄNDERN</a></td>");
out.println("<td><a href='delete.jsp?book=" + result.getString("id") + "'>LÖSCHEN</a></td>");
out.println("</tr>");
}
c.close();
%>
<!-- nicht titel Bücher in postgres verändern, weil sondern kein UUID wird gemacht!
Erst Mal müssen wir der UUID in POstgres anmachen---
uuid_generate_v4()--to insert in constraints, default-->
</table>
</body>
</html>