Skip to content

Instantly share code, notes, and snippets.

@jjl
Created May 10, 2016 08:43
Show Gist options
  • Save jjl/7cbbebdf8268baa66222fdf476974aa3 to your computer and use it in GitHub Desktop.
Save jjl/7cbbebdf8268baa66222fdf476974aa3 to your computer and use it in GitHub Desktop.
public ResultSetMetaData getMetaData() throws SQLException {
checkClosed();
ResultSet rs = getResultSet();
if (rs == null || ((PgResultSet) rs).isResultSetClosed()) {
// OK, we haven't executed it yet, or it was closed
// we've got to go to the backend
// for more info. We send the full query, but just don't
// execute it.
int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_DESCRIBE_ONLY
| QueryExecutor.QUERY_SUPPRESS_BEGIN;
StatementResultHandler handler = new StatementResultHandler();
connection.getQueryExecutor().execute(preparedQuery.query, preparedParameters, handler, 0, 0,
flags);
ResultWrapper wrapper = handler.getResults();
if (wrapper != null) {
rs = wrapper.getResultSet();
}
}
if (rs != null) {
return rs.getMetaData();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment