-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsp
72 lines (64 loc) · 2.36 KB
/
index.jsp
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
69
70
71
72
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<%@ include file="head.jsp" %>
<body class="container my-3">
<h1 class="text-center">CRUD JSP</h1>
<div class="d-flex justify-content-end">
<a class="btn btn-primary mb-3" href="tambah.jsp">Tambah</a>
</div>
<% try {
String Host = "jdbc:mysql://localhost:3306/koperasi";
Connection conn = null;
Statement st = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(Host, "root", "");
st = conn.createStatement(); String Data = "SELECT * FROM nasabah";
rs = st.executeQuery(Data);
%>
<table class="table table-success table-striped">
<thead>
<tr>
<th scope="col">Nama</th>
<th scope="col">Alamat</th>
<th scope="col">No HP</th>
<th scope="col">No Rekening</th>
<th scope="col">Jumlah Pinjaman</th>
<th scope="col">Aksi</th>
</tr>
</thead>
<tbody>
<%
while (rs.next()) {
%>
<tr>
<td><%=rs.getString("nama")%></td>
<td><%=rs.getString("alamat")%></td>
<td><%=rs.getString("no_hp")%></td>
<td><%=rs.getString("no_rekening")%></td>
<td><%=rs.getString("jumlah_pinjaman")%></td>
<td>
<a class="btn btn-primary" href="update.jsp?u=<%=rs.getString("no_rekening")%>">EDIT</a>
|
<a class="btn btn-danger" href="delete.jsp?d=<%=rs.getString("no_rekening")%>" onclick="return confirm('Apakah anda yakin akan menghapus <%=rs.getString("nama")%>?')">HAPUS</a>
</td>
</tr>
<% } %>
</tbody>
</table>
<%
rs.close();
st.close();
conn.close();
} catch (Exception ex) {
out.println("Can't connect to database.");
}
%>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>