0

My question is can, ResultSetMetaData.getColumnLabel(int) return null ?

Is there any known cases where any of the driver implementation return null ? If so, how to achieve that case.

From documentation, it seems there is no such restriction. I want a second opinion regarding this.

Update 1:

In PostgreSQL, when I execute a simple query select 1;, the returned column name ?column?. My question is, are there any scenarios where column label can be null.

suraj1291993
  • 474
  • 1
  • 5
  • 15

2 Answers2

1

The JDBC API doesn't explicitly forbid null as a value for getColumnLabel (or getColumnName), so it not impossible that there are JDBC implementations that return null for unnamed columns.

That said, I can't think of examples of the top of my head. As far as I'm aware, most databases generate a default label for unnamed columns.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
0

There cannot be a scenario where it can return null. Either it will return a value or an exception stating the no passed is more than available columns

Bimlendu
  • 21
  • 2
  • Updated the question with more a clearer problem statement. @Bimlendu – suraj1291993 Oct 02 '19 at 08:02
  • 1
    Why do you think that? The API doesn't explicitly forbid it, and it is entirely possible that there are databases that will yield `null` as the column label or column name for unnamed columns. – Mark Rotteveel Oct 02 '19 at 15:50