Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Metodo implements Mproceso{
- @Override
- public ArrayList mostrar() {
- Connection con;
- Statement st;
- ResultSet rs;
- ArrayList<Object> list = new ArrayList<>();
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/runner","root","");
- String q = "SELECT * FROM productos";
- st = con.createStatement();
- rs = st.executeQuery(q);
- while (rs.next()){
- for (int x = 0;x<st.getMaxFieldSize();x++){
- for (int y = 0;y<st.getMaxRows();y++){
- list.add(x,rs.getObject(y));
- }
- }
- }
- } catch (ClassNotFoundException | SQLException e) {
- e.printStackTrace();
- }
- return list;
- }
- <%@ page import="Model.Metodo" %>
- <%@ page import="java.util.ArrayList" %>
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <html>
- <head>
- <title>Titulo</title>
- </head>
- <body>
- <%
- Metodo m = new Metodo();
- ArrayList list = m.mostrar();
- for (Object a: list){
- %>
- <h1><%=a%></h1>
- <%
- }
- %>
- </body>
Add Comment
Please, Sign In to add comment