-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewuser.java
More file actions
67 lines (59 loc) · 1.92 KB
/
Copy pathviewuser.java
File metadata and controls
67 lines (59 loc) · 1.92 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author devi
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class viewuser extends HttpServlet{
Connection c=null;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
c=DriverManager.getConnection("jdbc:derby://localhost:1527/eticketing","kd","kd");
}catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}catch(SQLException se){
System.out.println(se.getMessage());
}catch(Exception ex){
System.out.println(ex.getMessage());
}
try{
PrintWriter out=response.getWriter();
Statement s=c.createStatement();
ResultSet rs = s.executeQuery("select * from users");
out.println("<html><table border='1'><tr>");
out.println("<td>NAME</td>");
out.println("<td>pw</td>");
out.println("<td>email</td>");
out.println("<td>Phoneno</td></tr>");
while(rs.next())
{
out.println("<tr><td>'"+rs.getString("usname")+"'</td>");
out.println("<td>'"+rs.getString("pw")+"'</td>");
out.println("<td>'"+rs.getString("email")+"'</td>");
out.println("<td>'"+rs.getString("phoneno")+"'</td></tr>");
}
out.println("</table></html>");
s.close();
c.close();
}catch(SQLException e){
System.out.println(e.getMessage());
}
finally
{
}
}
}