<%-- Document : exec_agregar_declarantes Created on : 02/10/2012, 12:40:32 horas Author : Martha --%> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import = "conexion.*" import = "dates.*" import = "java.sql.*" import = "general.Config" import = "general.Permisos" import = "java.util.Date" import = "java.text.SimpleDateFormat" %> Actualizando el sistema... <% /************************** Guarda los cambios hechos a los datos del usuario en la base de datos **************************************/ // out.println(""); //String nompag[] = request.getRequestURI().split("/"); %> <% //Connection lcnt_con = null; ResultSet lrs_res = null; Statement lst_stm = null; ResultSet lrs_res1 = null; Statement lst_stm1 = null; Statement lst_stm2 = null; /*Segunda Conexión*/ ConexionDeclara cd = null; Connection lcd_connection = null; //Statement lstg_conecta=null; /*FIN. SEGUNDA CONEXIÓN*/ String ls_query = new String(""); String emergent_error = new String(""); boolean lb_connection = false; String debug = new String("si"); String nombre = new String(""); /********* INICIO. Conexión a la base de datos ********/ try { /*if (!Config.getParametro("debug").equals("si")) { debug = "no"; }*/ cd = new ConexionDeclara(); lcd_connection = cd.getConnection(); lst_stm = lcd_connection.createStatement(); lst_stm1 = lcd_connection.createStatement(); lst_stm2 = lcd_connection.createStatement(); lb_connection = true; }catch (Exception e) { emergent_error = "Error al conectarse a la base de datos 2 "; } /********* FIN. Conexión a la base de datos ********/ //********* Validación fundamental para evitar ejecución de código sin privilegios suficientes **********// /*try { if (!Permisos.PermisoModulo(nompag[nompag.length - 1].toString(), Integer.parseInt(session.getAttribute("id_user").toString()))) { if (lb_connection) { lst_stm.close(); lcd_connection.close(); } emergent_error += " Privilegios insuficientes. "; lb_connection = false; } } catch (Exception e) { emergent_error += " Privilegios insuficientes. "; if (debug.equals("si")) { emergent_error += "Trace: " + e.toString(); } lb_connection = false; }*/ //*******************************************************************************************************// if (lb_connection) { try { /*fechaSesenta = suma.suma_dias(formato.parse(request.getParameter("fecha_inicio")), 60); dias = suma.diferenciasDeFechas(hoy, new java.util.Date(fechaSesenta.getTime())); if (dias <= 0)*/ %>
Actualizando la base de datos, espere por favor...
<% ls_query = "select puesto, id_funcionario from dente order by id_funcionario"; lrs_res = lst_stm.executeQuery(ls_query); while(lrs_res.next()){ out.println("
"); //nombre= lrs_res.getString("puesto").concat(" ".concat(lrs_res.getString("puesto2"))); //nombre=nombre.trim(); nombre= lrs_res.getString("puesto").replace("¥", "Ñ"); //ls_query ="update dente set nombre='"+nombre+"'" // +" where clave ='"+lrs_res.getString("puesto")+"'"; out.println(lrs_res.getString("id_funcionario")+" "+lrs_res.getString("puesto") ); out.println("
"); ls_query ="update dente set " + "puesto='"+nombre+"'" +" where id_funcionario ="+lrs_res.getString("id_funcionario"); out.println(ls_query); out.println("
"); lst_stm1.executeUpdate(ls_query); out.println("
"); } //Registrar en la bitácora /* try { String mensaje_log = new String(""); mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- agrego el Declarante Nuevo - " + id_funcionario + " , " + request.getParameter("nombre") + request.getParameter("ap_paterno") + request.getParameter("ap_materno") + " -;"; Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3); } catch (Exception e) { } session.setAttribute("mensaje_pendiente", "El sistema ha sido actualizado, los datos del Declarante - " + id_funcionario + " , " + request.getParameter("nombre") + request.getParameter("ap_paterno") + request.getParameter("ap_materno") + " - fueron actualizados."); lst_stm.executeUpdate("COMMIT;");*/ %> <% } catch (Exception e) { emergent_error = "Error al actualizar la base de datos "; lst_stm.executeUpdate("ROLLBACK;"); if (debug.equals("si")) { emergent_error += e + " Query actual: " + ls_query; } %>
<%=emergent_error%>
<% } finally { lst_stm.close(); lst_stm1.close(); lst_stm2.close(); lcd_connection.close(); } } else { %>
<%=emergent_error%>
<% } %>