title: Reading a XMLType column in a oracle DB using JDBC
body: <p>I am trying to read an XMLType column into a <code>Clob</code> type variable using JDBC. I am getting an error when I do this.... Any ideas?</p>
  
  <pre><code>java.sql.SQLException: Invalid column name
      at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:197)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:269)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:490)
      at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3353)
      at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1883)
      at oracle.jdbc.driver.OracleResultSet.getClob(OracleResultSet.java:358)
      at persistance.FilmDAO.findFilmsWithXML(FilmDAO.java:626)
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>public ArrayList&lt;FilmBean&gt; findFilmsWithXML() throws SQLException {
  
          ArrayList&lt;FilmBean&gt; filmList = new ArrayList&lt;FilmBean&gt;();
  
          try {
              currentConnection = ConnectionPool.getInstance().getConnection();
  
              String searchQuery = SqlHelper.getInstance().getSqlQuery(705);
  
              System.out.println("Query: " + searchQuery);
  
              currentStatement = currentConnection.prepareStatement(searchQuery);
  
              currentResultSet = currentStatement.executeQuery();
  
              while (currentResultSet.next()) 
              {
                  FilmBean filmDTO = new FilmBean();
                  filmDTO.setFilmId(Integer.parseInt(currentResultSet.getString("PK_ID_FILM")));
                  filmDTO.setPoster(currentResultSet.getString("POSTER"));
                  filmDTO.setTitle(currentResultSet.getString("TITLE"));
                  filmDTO.setXml(currentResultSet.getClob("MYXML"));
                  filmList.add(filmDTO);
              }
          }
          [...]
      }
  </code></pre>
  
  <p>The <code>setXml()</code> method sets a <code>Clob</code> type value into the <code>filmDTO</code> object in the model.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The query was missing an alias:</p>
  
  <pre><code>SELECT to_clob("MYXML") As MYCLOB, PK_ID_FILM, POSTER, TITLE FROM FILM Where MYXML is not null
  </code></pre>