0

我正在尝试Clob使用 JDBC 将 XMLType 列读入类型变量。执行此操作时出现错误....有什么想法吗?

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)

这是我的代码:

public ArrayList<FilmBean> findFilmsWithXML() throws SQLException {

        ArrayList<FilmBean> filmList = new ArrayList<FilmBean>();

        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);
            }
        }
        [...]
    }

setXml()方法将Clob类型值设置到filmDTO模型中的对象中。

编辑

查询缺少别名:

SELECT to_clob("MYXML") As MYCLOB, PK_ID_FILM, POSTER, TITLE FROM FILM Where MYXML is not null
4

1 回答 1

1

您在 之后缺少别名to_clob(XMLElement("MYXML"))。该列MYXML在查询中不存在。

于 2012-07-30T03:44:34.180 回答