Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.sql.*;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- /**
- * Servlet implementation class debugDb
- */
- @WebServlet("/debugDb")
- public class debugDb extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private int lol = 5;
- private String stat = "nic";
- public void init(ServletConfig config) throws ServletException {
- lol = 10;
- String dbJdbcUrl = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_68c31f5fa0315bf?user=WPISZ_USER&password=WPISZ_HASLO";
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- Connection connect = DriverManager.getConnection(dbJdbcUrl);
- Statement statement = connect.createStatement();
- ResultSet resultSet = statement
- .executeQuery("select * from debugtab");
- stat = "ok: ";
- while (resultSet.next())
- {
- stat += resultSet.getString("id");
- }
- } catch (Exception e) {
- stat = "dupa_4";
- e.printStackTrace();
- }
- }
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- response.setContentType("text/html");
- response.getWriter().print("lol = " + lol + " stat = " + stat);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement