Guest User

Untitled

a guest
Apr 7th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public class Metodo implements Mproceso{
  2.  
  3. @Override
  4. public ArrayList mostrar() {
  5.  
  6. Connection con;
  7. Statement st;
  8. ResultSet rs;
  9. ArrayList<Object> list = new ArrayList<>();
  10. try {
  11. Class.forName("com.mysql.jdbc.Driver");
  12. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/runner","root","");
  13. String q = "SELECT * FROM productos";
  14. st = con.createStatement();
  15. rs = st.executeQuery(q);
  16. while (rs.next()){
  17. for (int x = 0;x<st.getMaxFieldSize();x++){
  18. for (int y = 0;y<st.getMaxRows();y++){
  19. list.add(x,rs.getObject(y));
  20. }
  21. }
  22. }
  23. } catch (ClassNotFoundException | SQLException e) {
  24. e.printStackTrace();
  25. }
  26. return list;
  27. }
  28.  
  29. <%@ page import="Model.Metodo" %>
  30. <%@ page import="java.util.ArrayList" %>
  31. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  32. <html>
  33. <head>
  34. <title>Titulo</title>
  35. </head>
  36. <body>
  37. <%
  38. Metodo m = new Metodo();
  39. ArrayList list = m.mostrar();
  40. for (Object a: list){
  41. %>
  42. <h1><%=a%></h1>
  43. <%
  44. }
  45. %>
  46. </body>
Add Comment
Please, Sign In to add comment