1 |
package com.grundfos.gmatou.dataupload;
|
2 |
|
3 |
import java.io.IOException;
|
4 |
import java.sql.Connection;
|
5 |
import java.sql.PreparedStatement;
|
6 |
import java.sql.ResultSet;
|
7 |
|
8 |
import javax.servlet.ServletException;
|
9 |
import javax.servlet.http.HttpServlet;
|
10 |
import javax.servlet.http.HttpServletRequest;
|
11 |
import javax.servlet.http.HttpServletResponse;
|
12 |
|
13 |
/**
|
14 |
* Servlet implementation class GetConfig
|
15 |
*/
|
16 |
public class GetConfig extends HttpServlet {
|
17 |
private static final long serialVersionUID = 1L;
|
18 |
|
19 |
/**
|
20 |
* @see HttpServlet#HttpServlet()
|
21 |
*/
|
22 |
public GetConfig() {
|
23 |
super();
|
24 |
// TODO Auto-generated constructor stub
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
29 |
*/
|
30 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
31 |
|
32 |
try
|
33 |
{
|
34 |
Connection conn = DBConnection.getDbConnection();
|
35 |
PreparedStatement stmt = conn.prepareStatement("SELECT value FROM config");
|
36 |
ResultSet rs = stmt.executeQuery();
|
37 |
String data = " -- no config data found --";
|
38 |
while (rs.next())
|
39 |
data = rs.getString(1);
|
40 |
|
41 |
rs.close();
|
42 |
stmt.close();
|
43 |
conn.close();
|
44 |
|
45 |
response.setContentType("text/plain");
|
46 |
response.getWriter().print(data);
|
47 |
|
48 |
|
49 |
} catch (Exception e) {
|
50 |
throw new ServletException(e);
|
51 |
}
|
52 |
}
|
53 |
|
54 |
}
|