Oracle - Problemas en mostrar datos en la tabla

 
Vista:
sin imagen de perfil
Val: 1
Ha disminuido su posición en 13 puestos en Oracle (en relación al último mes)
Gráfica de Oracle

Problemas en mostrar datos en la tabla

Publicado por Carlos (1 intervención) el 28/06/2019 22:24:17
Buenas tarde,tengo un problema y es que no me muestra los datos en la tabla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package daoimpl;
 
import DAO.formulariodao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import model.Formulario;
import util.conexion;
 
public class formulariodaoimp implements formulariodao {
 
    @Override
    public String agregar(Formulario formulario) {
        Connection cn = null;
        String mensaje = "";
        try {
            cn = conexion.getconexion();
            String sql = "INSERT INTO FORMULARIO_PRUEBA VALUES(?,?,?,?,?,?,?)";
            PreparedStatement pstm = cn.prepareStatement(sql);
            pstm.setString(1, formulario.getId_usuario());
            pstm.setString(2, formulario.getContraseña());
            pstm.setString(3, formulario.getNombre());
            pstm.setString(4, formulario.getApellido());
            pstm.setString(5, formulario.getCorreo());
            pstm.setInt(6, formulario.getTelefono());
            pstm.setString(7, formulario.getDireccion());
            pstm.executeUpdate();
            mensaje = "Agregado";
        } catch (SQLException e) {
            mensaje = e.toString();
        } finally {
            try {
                if (cn != null && !cn.isClosed()) {
                    cn.close();
                }
            } catch (SQLException ex) {
                ex.printStackTrace(System.out);
            }
        }
        return mensaje;
    }
}

1
2
3
4
5
6
7
8
9
10
package DAO;
 
import model.Formulario;
 
 
public interface formulariodao {
 
    public String agregar(Formulario formulario);
 
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package daoimpl;
 
import DAO.formulariodao;
import java.sql.Connection;
import java.sql.PreparedStatement;
 
import model.Formulario;
import util.conexion;
 
 
public class formulariodaoimp  implements formulariodao {
    Connection cn = conexion.getconexion();
 
 
    @Override
    public String agregar(Formulario formulario) {
        String mensaje= "";
        try {
            String sql = "INSERT INTO FORMULARIO_PRUEBA VALUES(?,?,?,?,?,?,?)";
            PreparedStatement pstm = cn.prepareStatement(sql);
 
            pstm.setString(0, formulario.getId_usuario());
            pstm.setString(1, formulario.getContraseña());
            pstm.setString(2, formulario.getNombre());
            pstm.setString(3, formulario.getApellido());
            pstm.setString(4, formulario.getCorreo());
            pstm.setInt(5, formulario.getTelefono());
            pstm.setString(6, formulario.getDireccion());
 
            pstm.executeUpdate();
            mensaje="Agregado";
 
        } catch (Exception e) {
            mensaje= e.toString();
        }
        return mensaje;
        }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package model;
 
 
public class Formulario {
     private String id_usuario;
     private String contraseña;
     private String nombre;
     private String apellido;
     private String correo;
     private int telefono;
     private String direccion;
 
    public Formulario() {
    }
 
    public Formulario(String id_usuario, String contraseña, String nombre, String apellido, String correo, int telefono, String direccion) {
        this.id_usuario = id_usuario;
        this.contraseña = contraseña;
        this.nombre = nombre;
        this.apellido = apellido;
        this.correo = correo;
        this.telefono = telefono;
        this.direccion = direccion;
    }
 
    public String getDireccion() {
        return direccion;
    }
 
    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }
 
    public String getId_usuario() {
        return id_usuario;
    }
 
    public void setId_usuario(String id_usuario) {
        this.id_usuario = id_usuario;
    }
 
    public String getContraseña() {
        return contraseña;
    }
 
    public void setContraseña(String contraseña) {
        this.contraseña = contraseña;
    }
 
    public String getNombre() {
        return nombre;
    }
 
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
 
    public String getApellido() {
        return apellido;
    }
 
    public void setApellido(String apellido) {
        this.apellido = apellido;
    }
 
    public String getCorreo() {
        return correo;
    }
 
    public void setCorreo(String correo) {
        this.correo = correo;
    }
 
    public int getTelefono() {
        return telefono;
    }
 
    public void setTelefono(int telefono) {
        this.telefono = telefono;
    }
 
 
 
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package servlet;
 
import daoimpl.formulariodaoimp;
import java.io.IOException;
/*import java.io.PrintWriter;*/
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Formulario;
 
 
public class formularioservlet extends HttpServlet {
 
    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    formulariodaoimp formulariodao = new formulariodaoimp();
 
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        request.setCharacterEncoding("UTF-8");
 
        String accion = request.getParameter("accion");
        if (accion.equalsIgnoreCase("agregarregistro")) {
            agregarregistro(request, response);
        }
 
    }
 
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
 
    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
 
    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
 
    private void agregarregistro(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
        try {
            String usuario = request.getParameter("txtusuario");
            String contraseña = request.getParameter("txtpass");
            String Nombre = request.getParameter("txtnombre");
            String apellido = request.getParameter("txtapellido");
            String correo = request.getParameter("txtcorreo");
            int telefono = Integer.parseInt(request.getParameter("txtTel"));
            String Direccion = request.getParameter("txtdireccion");
 
            Formulario formulario = new Formulario(usuario, contraseña, Nombre, apellido, correo, telefono, Direccion);
           // formulario.setId_usuario(usuario);
            //formulario.setContraseña(contraseña);
            //formulario.setNombre(Nombre);
            //formulario.setApellido(apellido);
            //formulario.setCorreo(correo);
            //formulario.setTelefono(telefono);
            //formulario.setDireccion(Direccion);
 
 
            String mensaje = formulariodao.agregar(formulario);
 
            if(mensaje.equals("Agregado")){
               request.setAttribute("mensaje", mensaje);
            }else{
 
            request.setAttribute("error", mensaje);
            }
 
            request.getRequestDispatcher("rfmformulario.jsp").forward(request, response);
 
        } catch (Exception e) {
            request.setAttribute("error", e);
            request.getRequestDispatcher("index.html").forward(request, response);
        }
 
    }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder