Rabu, 15 Mei 2024

utorial memang tabel crud dengan jsp

Post oleh : http://muhajirkelanasaputra.blogspot.com/ | Rilis : 21.50 | Series :
ini tipe database nya
<%--     Document   : readUsers    Created on : May 15, 2024, 11:02:42 PM    Author     : Muhajir K.S--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE html><html><head>  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  <title>Read Users</title>  <!-- Link to Bootstrap CSS -->  <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"></head><body>  <%@page import = "java.sql.*" %>  <div class="container">    <h1 class="mt-5">Read Users</h1>    <!-- Add Create User Button -->    <a href="createUser.jsp" class="btn btn-primary mb-3">Create User</a>    <table class="table table-striped mt-3">      <thead>        <tr>          <th>Id</th>          <th>First Name</th>          <th>Last Name</th>          <th>Address</th>          <th>Email</th>          <th>Phone</th>          <th>Profession</th>          <th>Actions</th>        </tr>      </thead>      <tbody>        <%         Connection connection = null;         Statement statement = null;         ResultSet resultSet = null; 
        try {           String connectionURL = "jdbc:mysql://localhost/perusahaan";           String userName = "root";           String passWord = "";           Class.forName("com.mysql.jdbc.Driver");           connection = DriverManager.getConnection(connectionURL, userName, passWord);           statement = connection.createStatement(); 
          String query = "SELECT * FROM employee";           resultSet = statement.executeQuery(query); 
          while(resultSet.next()) {         %>        <tr>          <td><%= resultSet.getString("ID") %></td>          <td><%= resultSet.getString("Firstname") %></td>          <td><%= resultSet.getString("Lastname") %></td>          <td><%= resultSet.getString("Address") %></td>          <td><%= resultSet.getString("Email") %></td>          <td><%= resultSet.getString("Phone") %></td>          <td><%= resultSet.getString("Profession") %></td>          <td>            <a href="updateUser.jsp?id=<%= resultSet.getString("ID") %>" class="btn btn-warning btn-sm">Update</a>            <a href="deleteUser.jsp?id=<%= resultSet.getString("ID") %>" class="btn btn-danger btn-sm">Delete</a>          </td>        </tr>        <%           }           resultSet.close();           statement.close();           connection.close();         } catch(Exception e) {           out.println(e.getMessage());         }         %>      </tbody>    </table>  </div>  <!-- Link to Bootstrap JS and dependencies -->  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>  <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script></body></html>


google+

linkedin