title: How to get all columns' names from an Oracle table
body: <p>How can I get all columns' names from an Oracle table using Java?
  Is there a way to get them from DatabaseMetaData object?</p>
  
  <pre><code>DatabaseMetaData myDatabaseMetaData = myConnection.getMetaData();
  ...
  </code></pre>
  
  <p>I know I can get them using a select statement:</p>
  
  <pre><code>Select COLUMN_NAME from user_tab_columns where table_name='MYTABLE'
  </code></pre>
  
  <p>If it is possible to get them from DatabaseMetaData object, what is the difference between the two methods?</p>
  
  <p>EDIT: Posting working code (thanks for your answers)</p>
  
  <pre><code>public ArrayList&lt;String&gt; getAllFields(String tableName) {
      ArrayList&lt;String&gt; allFields = new ArrayList&lt;String&gt;();
      try {
          DatabaseMetaData myDatabaseMetaData = myConnection.getMetaData();
          ResultSet columnsResultSet = myDatabaseMetaData.getColumns(null, null, tableName, null);
          while (columnsResultSet.next()) { allFields.add(columnsResultSet.getString("COLUMN_NAME")); }
      } catch (SQLException ex) {
          Exceptions.printStackTrace(ex);
      }
      return allFields;
  }
  </code></pre>