summaryrefslogtreecommitdiff
path: root/app/v2_java/src/org/usi2011/Question.java
blob: 0c391d3d2b8eedbc780c69092d19276d24789979 (plain)
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
67
package org.usi2011;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class question
 */
public class Question extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Connection connection;
	/**
	 * Default constructor.
	 */
	public Question() {
		super();
		connection = Database.getConnection();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ServletOutputStream out = response.getOutputStream();
		
		try {
			String query = "INSERT INTO game VALUES (1, 2, 3, 4, 5)";
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(query);
			query = "SELECT * FROM game";
			statement = connection.createStatement();
			resultset = statement.executeQuery(query);
			while (resultset.next()) {
				out.println(resultset.getString(1));
			}
		} catch (SQLException e) {
			response.sendError(400);
		}
		
		
		out.println("hello world");
		out.println(request.getRequestURI());
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}