Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.io.*, java.util.*, java.net.*, java.sql.*"%>
- <%@ include file="conexion.jsp"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >>
- <html>
- <head><title>Listado de Productos</title></head>
- <body>
- Los productos que el usuario ha comprado son:
- <p></p>
- <center>
- <%
- out.println("<table border=1>");
- out.println("<tr><th>Id del producto</th><th>Nombre</th><th>Descrición</th><th>Categoria</th><th>Usuario</th><th>Precio</th></tr>");
- try{
- //Aqui se abre la conexion
- String conexion = ("jdbc:mysql://localhost/BDIS user="+usuarioMysql()+"&password="+passwordMysql());
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- //Connection con = DriverManager.getConnection("jdbc:mysql://localhost/BDIS", "root","mellon");
- Connection con = DriverManager.getConnection(conexion);
- Statement st = con.createStatement();
- //Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
- //NOTA: Acá conviene que ponga "Where NOM_USU= 'usuario'"
- ResultSet res = st.executeQuery("select * from ProductoBD;");
- //Acá irían los datos pero no los despliega no sé porque
- while(res.next()){
- out.println("<tr><td>"+res.getInt(1)+"</td><td>"+res.getString(2)+"</td><td>"+res.getString(3)+"</td><td>"+res.getInt(4)+"</td><td>"+res.getString(5)+"</td><td>"+res.getDouble(5)+"</td></tr>");
- }
- out.println("</table>");
- }
- catch(ClassNotFoundException cnfe){
- cnfe.printStackTrace();
- }
- catch(SQLException sqle){
- sqle.printStackTrace();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- %>
- </center></body>
- <html>
Add Comment
Please, Sign In to add comment