0

According to this question: Getting output from dbms_output.get_lines using JDBC

I used the code:

try (Statement s = conn1.createStatement()) {

    try {
        s.executeUpdate("begin dbms_output.enable(); end;");
        s.executeUpdate("begin dbms_output.put_line('abc'); end;");
        s.executeUpdate("begin dbms_output.put_line('hello'); end;");
        s.executeUpdate("begin dbms_output.put_line('so cool'); end;");

        try (CallableStatement call = conn1.prepareCall(
            "declare "
          + "  num integer := 1000;"
          + "begin "
          + "  dbms_output.get_lines(?, num);"
          + "end;"
        )) {
            call.registerOutParameter(1, java.sql.Types.ARRAY, "DBMSOUTPUT_LINESARRAY");
            call.execute();

            Array array = null;
            try {
                array = call.getArray(1);
                System.out.println(Arrays.asList((Object[]) array.getArray()));
            }
            finally {
                if (array != null)
                    array.free();
            }
        }
    }
    finally {
        s.executeUpdate("begin dbms_output.disable(); end;");
    }
}

but received as a result:

[???, ???, ???, null]

when i was supposed to get:

[abc, hello, so cool, null]

What could be the reason for this and how can this be fixed?

Seiya
  • 31
  • 1

2 Answers2

0

Including orai18n.jar to the project libraries solved this...

Seiya
  • 31
  • 1
0

Just including orai18n.jar to the project libraries solved this. This jar has the configuration information to support all Oracle character sets in Advance Data Types (Objects).

  • This is a duplicated answer to a one year old post, the OP provided this answer just a couple of hours after posting the question – Ana GH May 24 '22 at 10:04