1 |
package dk.daoas.daoadresseservice.db;
|
2 |
|
3 |
import java.io.IOException;
|
4 |
import java.io.PrintWriter;
|
5 |
import java.sql.Connection;
|
6 |
import java.sql.SQLException;
|
7 |
|
8 |
import javax.servlet.ServletException;
|
9 |
import javax.servlet.annotation.WebServlet;
|
10 |
import javax.servlet.http.HttpServlet;
|
11 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletResponse;
|
13 |
|
14 |
|
15 |
@WebServlet("/DbConnectionProbe")
|
16 |
public class DbConnectionProbe extends HttpServlet {
|
17 |
private static final long serialVersionUID = 1L;
|
18 |
|
19 |
public DbConnectionProbe() {
|
20 |
super();
|
21 |
// TODO Auto-generated constructor stub
|
22 |
}
|
23 |
|
24 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
25 |
response.setContentType("text/html");
|
26 |
PrintWriter out = response.getWriter();
|
27 |
|
28 |
out.print("<html><head><title>DaoAdresseService</title></head><body>");
|
29 |
out.print("<h2>DaoAdresseService</h2>");
|
30 |
try {
|
31 |
Connection conn = DBConnection.getConnection();
|
32 |
conn.close();
|
33 |
out.print("Got DB Connection");
|
34 |
|
35 |
} catch (SQLException e) {
|
36 |
out.print("DB Connection failed: " + e.getMessage());
|
37 |
}
|
38 |
|
39 |
|
40 |
}
|
41 |
|
42 |
}
|