public boolean crearAuditoriaPorTabla(String schema, String nombre) {
        borrarTriggers(schema, nombre);
        try {
            Connection con = this.connecting();
            String sql;
            if (con != null) {
                try (Statement stmt = con.createStatement()) {
                    int cont = 0;
                    String s1 = "";
                    String s2 = "";
                    if (cont == 0) {
                        ResultSet rs = stmt.executeQuery("select * from INFORMATION_SCHEMA.COLUMNS where table_schema = '" + schema + "' AND table_name = '" + nombre + "';");
                        String conn = "";
                        sql = "CREATE TABLE IF NOT EXISTS " + nombre + " (";
                        sql += "_id serial NOT NULL,";
                        String insert = "insert into " + nombre + " (";
                        String values = " values (";
                        while (rs.next()) {
                            String columnName = rs.getString("column_name");
                            String columnType = rs.getString("data_type").trim();
                            String tmp = rs.getString("character_maximum_length");
                            insert += s1 + columnName;
                            values += s2 + " ' || CASE WHEN NEW." + columnName + " IS NULL THEN 'NULL' ELSE '''' || NEW." + columnName + " || '''' END " + " || ' ";
                            s1 = ",";
                            s2 = ",";
                            int maxCharacter = 0;
                            if (tmp != null) {
                                maxCharacter = Integer.parseInt(rs.getString("character_maximum_length"));
                            }

                            if (columnType.equalsIgnoreCase("character varying") || columnType.equalsIgnoreCase("varchar")) {
                                sql += columnName + " " + columnType + "(" + maxCharacter + "),";
                            } else {
                                sql += columnName + " " + columnType + ",";
                            }
                        }
                        sql += "_accion varchar(50),";
                        sql += "_fecha timestamp DEFAULT current_timestamp );";
                        conn += " select dblink('dbname=" + audit_base + " host=" + host + " user=" + audit_usuario + " password=" + audit_clave + "', '" + sql + "');";

                        insert += ",_accion)";
                        values += ",''' || TG_OP || ''')";
                        String union = insert;
                        System.out.print(conn);
                        stmt.execute(conn);
                        try {
                            stmt.execute("select dblink('dbname=" + audit_base + " host=" + host + " user=" + audit_usuario + " password=" + audit_clave + "', 'ALTER TABLE " + nombre + " ADD CONSTRAINT pk_" + nombre + " PRIMARY KEY(_id);');");
                        } catch (SQLException ex) {
                            System.err.println("Error, pk_" + nombre + " la tabla " + nombre + "ya existe.");
                        }
                        String funcion = "CREATE OR REPLACE FUNCTION auditor_" + schema + "_" + nombre + "() RETURNS TRIGGER AS \n"
                                + "$trigger_audit$\n"
                                + "BEGIN\n"
                                + "    PERFORM dblink('dbname=" + audit_base + " host=" + host + " user=" + audit_usuario + " password=" + audit_clave + "', '" + insert + values + "' );\n"
                                + "    RETURN null;\n"
                                + "END;\n"
                                + "$trigger_audit$ LANGUAGE plpgsql VOLATILE COST 100;";
                        stmt.execute(funcion);

                        funcion = "CREATE OR REPLACE FUNCTION auditor_" + schema + "_" + nombre + "_del() RETURNS TRIGGER AS \n"
                                + "$trigger_audit$\n"
                                + "BEGIN\n"
                                + "    PERFORM dblink('dbname=" + audit_base + " host=" + host + " user=" + audit_usuario + " password=" + audit_clave + "', '" + insert + values + "' );\n"
                                + "    RETURN null;\n"
                                + "END;\n"
                                + "$trigger_audit$ LANGUAGE plpgsql VOLATILE COST 100;";
                        funcion = funcion.replaceAll("NEW.", "OLD.");
                        stmt.execute(funcion);

                        String trigger = "DROP TRIGGER IF EXISTS trigger_auditor_" + schema + "_" + nombre + " ON " + nombre + ";CREATE TRIGGER trigger_auditor_" + schema + "_" + nombre + "\n"
                                + "AFTER INSERT OR UPDATE ON \"" + nombre + "\"\n"
                                + "    FOR EACH ROW EXECUTE PROCEDURE auditor_" + schema + "_" + nombre + "();";
                        stmt.execute(trigger);

                        trigger = "DROP TRIGGER IF EXISTS trigger_auditor_" + schema + "_" + nombre + "_del ON " + nombre + ";CREATE TRIGGER trigger_auditor_" + schema + "_" + nombre + "_del\n"
                                + "AFTER DELETE ON \"" + nombre + "\"\n"
                                + "    FOR EACH ROW EXECUTE PROCEDURE auditor_" + schema + "_" + nombre + "_del();";
                        stmt.execute(trigger);

                        System.out.println(funcion + trigger);
                        return true;
                    }
                }
//                con.close();
            } else {
                System.err.println("Error en la conexion con la base de datos");
            }
        } catch (SQLException e) {
            System.err.println(e.getMessage());
        }
        return false;
    }