我正在尝试使用JDBC将XMLType列读入Clob
类型变量。当我这样做时,我收到了一个错误....任何想法?
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
答案 0 :(得分:1)
您在to_clob(XMLElement("MYXML"))
之后缺少别名。查询中不存在MYXML
列。