1

Is it possible to get "hints" formatted query output using oracle jdbc driver?

example query

Select /*insert*/ * from sample_table

or

Select /*html*/ * from sample_table

looks like the stmt.executeQuer is just ignoring formatting "hints" and only return Select * results

        try {
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("Select /*insert*/ * from sample_table where ID = 1");

            while (rs.next()) {
                inserts.add(rs.getString(1));                    
            }
        } catch (SQLException e) {
            log.error("SQL Error", e);
        } finally {

UPD: As mentioned in the comments the /*insert*/ "hint" is specific to the SQL Developer and SQLcl clients.

I was able to get the query formatted output from SQLcl client enter image description here

The eventual goal is to get formatted query output from Java code. So re-phrasing the question: how to run query and get output through SQLcl using java ?

David Abragimov
  • 524
  • 2
  • 6
  • 24
  • Well your example `/*insert*/` is a *comment* - not a *hint*. And *comments* are ignored. But what is the question? – Marmite Bomber Feb 18 '21 at 22:21
  • @Marmite Bomber it's not comment. please see https://www.oreilly.com/library/view/oracle-sql-developer/9781785281273/ch02s10.html. You can try query in SQL Developer – David Abragimov Feb 18 '21 at 22:26
  • 6
    we implemented that feature on top of the driver in our client tools (sqldev, sqlcl) – thatjeffsmith Feb 18 '21 at 22:31
  • 5
    Those hints (and the `set sqlfomat` version/enhancement) are specific to the SQL Developer and SQLcl clients. They aren't part of SQL so don't mean anything to JDBC or anything else - they are treated as comments everywhere else. – Alex Poole Feb 18 '21 at 23:39

0 Answers0