title: JDBC DatabaseMetaData.getColumns() returns duplicate columns
body: <p>I'm busy on a piece of code to get alle the column names of a table from an Oracle database. The code I came up with looks like this:</p>
  
  <pre><code>DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
  Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@&lt;server&gt;:1521:&lt;sid&gt;", &lt;username&gt;, &lt;password&gt;);
  
  DatabaseMetaData meta = conn.getMetaData();
  ResultSet columns = meta.getColumns(null, null, "EMPLOYEES", null);
  int i = 1;
  while (columns.next())
  {
    System.out.printf("%d: %s (%d)\n", i++, columns.getString("COLUMN_NAME"), 
      columns.getInt("ORDINAL_POSITION"));
  }
  </code></pre>
  
  <p>When I ran this code to my surprise too many columns were returned. A closer look revealed that the ResultSet contained a duplicate set of all the columns, i.e. every column was returned twice. Here's the output I got:</p>
  
  <pre><code>1: ID (1)
  2: NAME (2)
  3: CITY (3)
  4: ID (1)
  5: NAME (2)
  6: CITY (3)
  </code></pre>
  
  <p>When I look at the table using Oracle SQL Developer it shows that the table only has three columns (ID, NAME, CITY). I've tried this code against several different tables in my database and some work just fine, while others exhibit this weird behaviour.</p>
  
  <p>Could there be a bug in the Oracle JDBC driver? Or am I doing something wrong here?</p>
  
  <hr>
  
  <p><strong>Update:</strong> Thanks to <a href="https://stackoverflow.com/users/13317/kenster">Kenster</a> I now have an alternative way to retrieve the column names. You can get them from a ResultSet, like this:</p>
  
  <pre><code>DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
  Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@&lt;server&gt;:1521:&lt;sid&gt;", &lt;username&gt;, &lt;password&gt;);
  
  Statement st = conn.createStatement();
  ResultSet rset = st.executeQuery("SELECT * FROM \"EMPLOYEES\"");
  ResultSetMetaData md = rset.getMetaData();
  for (int i=1; i&lt;=md.getColumnCount(); i++)
  {
      System.out.println(md.getColumnLabel(i));
  }
  </code></pre>
  
  <p>This seems to work just fine and no duplicates are returned! And for those who wonder: according to <a href="http://olabini.com/blog/2008/01/are-you-using-resultsetmetadatagetcolumnname/" rel="nofollow noreferrer">this blog</a> you should use getColumnLabel() instead of getColumnName().</p>