0
See below for a java code to save an SQL command return in Postgresql. The command is EXPLAIN ANALYZE. The problem is that while saving this in the database, it loses line breaks. Someone would know how to help me solve this, that is, so that when selecting and recovering the text it comes with line breaks and indentations. The field that I need from this is the FULL_EXPLAIN below, and its data type is the "text" of postgresql.
---------------- JAVA CODE ---------------------
StringBuilder ConsultaExplain = new StringBuilder();
ConsultaExplain.append("EXPLAIN (ANALYZE, BUFFERS) ");
ConsultaExplain.append(SQLtxtQuery);
ResultSet result2 = BancoDeDados.getResultSet(ConsultaExplain.toString());
StringBuilder str1 = new StringBuilder();
str1.append("Execution plan...:");
SQLtxtQuery2 = SQLtxtQuery;
while (result2.next()) {
SQLtxtQuery2 = result2.getString(1);
str1.append(SQLtxtQuery2);
}
String myString = str1.toString();
String myNewStringNoQuotes = myString.replaceAll("'", "_");
StringBuilder exeSQLUpdateTabAcao = new StringBuilder();
exeSQLUpdateTabAcao.append(
"UPDATE TAB_CTRL_TEMPO SET OCORRENCIA_TEMPO= current_timestamp, FULL_EXPLAIN ='");
exeSQLUpdateTabAcao.append(myNewStringNoQuotes);
exeSQLUpdateTabAcao.append("' WHERE id = currval('tab_ctrl_tempo_id_seq')");
BancoDeDados.execStatement(exeSQLUpdateTabAcao.toString());