
09/03/2011, 16:19
|
 | | | Fecha de Ingreso: noviembre-2008 Ubicación: Ica
Mensajes: 295
Antigüedad: 16 años, 3 meses Puntos: 0 | |
insert into saludos gentita estoy en pininos de java, tengo una tabla productos ya me sale el mostrar, pero tengo problemas con el insert adjunto el code
nuevo_producto.jps
<%
// declarando y creando objetos globales
Connection canal = null;
ResultSet tabla= null;
Statement instruccion=null;
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
canal=DriverManager.getConnection("Jdbc:odbc:DBMAN TENIMIENTO");
instruccion = canal.createStatement(ResultSet.TYPE_SCROLL_SENSIT IVE,
ResultSet.CONCUR_UPDATABLE);
} catch(java.lang.ClassNotFoundException e){} catch(SQLException e) {};
String cod, nom, pre;
Statement stm = null;
int res=0;
// detectando y cargando el objeto submit de html
if(request.getParameter("cons") != null)
{
// abriendo canal o enlace en su propio try-catch
//try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
nom=request.getParameter("NOMBRE");
pre=request.getParameter("PRECIO");
cod=request.getParameter("CODCAT");
try { String orden ="insert into productos values ('" + nom + "','" + pre + "','" + nom + "')");
///AKI ESTA EL PROBLEM
stm = canal.createStatement();
res = stm.executeUpdate(orden);
tabla.close(); instruccion.close(); canal.close();} //fin try no usar ; al final de dos o mas catchs
catch(SQLException e) {};
};
// construyendo forma dinamica
out.println("<FORM ACTION=nuevo_producto.jsp METHOD=post>");
out.println("NOMBRE DEL PRODUCTO<INPUT TYPE=TEXT NAME=NOMBRE> <BR>");
out.println("PRECIO <INPUT TYPE=TEXT NAME=PRECIO> <BR>");
out.println("CODIGO CATEGORIA<INPUT TYPE=TEXT NAME=CODCAT> <BR>");
out.println("<INPUT TYPE=SUBMIT NAME=nuevo VALUE=NUEVO><BR>");
out.println("</FORM>");
%>
Se agradece cualquier apoyo. |