我正在尝试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