0

i'm creating plugin for website using JSP with servlets, and i stuck, I want to create output table of specific data from database and opportunity to select one row from the table and like example do more functions like Delete data or edit. But I can't imagine how to do it, even is it possible ? Here is my output:

    <table border="2">
<tr>
<td>ID</td>
<td>Name</td>
<td>Surname</td>
<td>Birth</td>
<td>Country</td>
<td>City</td>
<td>SSN</td>
</tr>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
 <%@ page import="java.sql.Statement" %>
  <%@ page import="java.sql.SQLException" %>
  <%@ page import="java.sql.ResultSet" %>

<%

    Connection connection = null;
Statement stmt = null;
ResultSet rs = null;


try
{

Class.forName("com.mysql.jdbc.Driver");

String query="select pad_code,firstname,surname,birth,country,city,ssn from pacient";
Connection conn=DriverManager.getConnection("jdbc:mysql://rude.su.lt:3306/selvenis_kursinis","****", "****");
 stmt=conn.createStatement();
 rs=stmt.executeQuery(query);

while(rs.next())
{

%>
    <tr><td><%=rs.getInt("pad_code") %></td>
    <td><%=rs.getString("firstname") %></td>
    <td><%=rs.getString("surname") %></td>
    <td><%=rs.getInt("birth") %></td>
    <td><%=rs.getString("country") %></td>
    <td><%=rs.getString("city") %></td>
    <td><%=rs.getInt("ssn") %></td></tr>
        <%

}
%>
    </table>
    <%
    rs.close();
    stmt.close();
    conn.close();
    }
catch(Exception e)
{
    e.printStackTrace();
    }


%>
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

When you want to modify your database, you need to send a HTTP request which describes your modification. For example, when pad_code is your primary key, you could send a HTTP DELETE request containing your pad_code.

Therefore, you need to create a form or a javascript function which will send this request. Finally, you need to update your UI (e.g. reload or AJAX).

schrieveslaach
  • 1,689
  • 1
  • 15
  • 32