Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1.  
  2.  
  3. import java.io.IOException;
  4. import java.sql.*;
  5.  
  6. import javax.servlet.ServletConfig;
  7. import javax.servlet.ServletException;
  8. import javax.servlet.annotation.WebServlet;
  9. import javax.servlet.http.HttpServlet;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12.  
  13. /**
  14.  * Servlet implementation class debugDb
  15.  */
  16. @WebServlet("/debugDb")
  17. public class debugDb extends HttpServlet {
  18.     private static final long serialVersionUID = 1L;
  19.  
  20.     private int lol = 5;
  21.     private String stat = "nic";
  22.  
  23.     public void init(ServletConfig config) throws ServletException {
  24.         lol = 10;
  25.        
  26.         String dbJdbcUrl = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_68c31f5fa0315bf?user=WPISZ_USER&password=WPISZ_HASLO";
  27.        
  28.         try
  29.         {
  30.             Class.forName("com.mysql.jdbc.Driver");
  31.             Connection connect = DriverManager.getConnection(dbJdbcUrl);
  32.            
  33.             Statement statement = connect.createStatement();
  34.          
  35.             ResultSet resultSet = statement
  36.               .executeQuery("select * from debugtab");
  37.  
  38.             stat = "ok: ";
  39.  
  40.             while (resultSet.next())
  41.             {
  42.                 stat +=  resultSet.getString("id");
  43.             }
  44.            
  45.            
  46.         } catch (Exception e) {
  47.             stat = "dupa_4";
  48.             e.printStackTrace();
  49.         }
  50.        
  51.     }
  52.  
  53.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  54.         response.setContentType("text/html");
  55.         response.getWriter().print("lol = " + lol + " stat = " + stat);
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement