java.sql.SQLException:无法转换为内部表示异常

请找到我的以下查询,
select nvl(max(transaction_id),0) as transaction_id from exception_details;
如果我通过我的jdbc代码执行上面的查询,它给了我java.sql.SQLException:无法转换为内部表示
我的JDBC代码如下:
public int fetchColumnVal(String query) throws SQLException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException, ClassNotFoundException, InstantiationException {
PreparedStatement pstmt = null;
Connection con = null;
try {
con = getConnection(true);
pstmt = con.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
rs.next();
int count=rs.getInt(1);
return count;
} finally {
if (isBatchMode) {
this.cleanResources(null, pstmt);
}
else {
this.cleanResources(con, pstmt);
}
}
}
并且表中的transaction_id列的数据类型是NUMBER
解决方法:
如果你使用@Enumerated而没有定义EnumType.STRING,即
@Enumerated(EnumType.STRING)
并且您的表已经包含String数据(Varchar),您将收到此错误,cos.
默认EnumType是ORDINAL,即EnumType.ORDINAL.