Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. String nome = request.getParameter("nome");
  2. String curso = request.getParameter("curso");
  3. String turma = request.getParameter("turma");
  4. String texto = request.getParameter("texto");
  5. /* TODO output your page here. You may use following sample code. */
  6. String driver = "com.mysql.jdbc.Driver";
  7. String url = "jdbc:mysql://localhost:3306/denuncia";
  8. String username = "root";
  9. String password = "";
  10.  
  11. try {
  12. Class.forName(driver);
  13. Connection connection = DriverManager.getConnection(url, username, password);
  14. Statement statment = connection.createStatement();
  15. String insert = "INSERT INTO denuncia VALUES('"+nome+"','"+turma+"','"+texto+"','"+curso+"')";
  16. statment.executeUpdate(insert);
  17. connection.close();
  18.  
  19. } catch(ClassNotFoundException cnfe) {
  20. out.println(cnfe);
  21. } catch(SQLException sqle) {
  22. out.println(sqle);
  23. }
  24.  
  25.  
  26. out.println("<!DOCTYPE html>");
  27. out.println("<html>");
  28. out.println("<head>");
  29. out.println("<title> Pronto </title>");
  30. out.println("</head>");
  31. out.println("<body>");
  32. out.println("<h1> Denuncia Realizada com sucesso </h1>");
  33. out.println("</body>");
  34. out.println("</html>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement