gpt4 book ai didi

java.sql.SQLException : Fail to convert to internal representation Exception 异常

转载 作者:搜寻专家 更新时间:2023-11-01 03:38:46 25 4
gpt4 key购买 nike

请找到我下面的查询,

select nvl(max(transaction_id),0) as  transaction_id from exception_details;

如果我通过我的 jdbc 代码执行上述查询,它会给我 java.sql.SQLException: Fail to convert to internal representation我的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

最佳答案

如果你在没有定义 EnumType.STRING 的情况下使用 @Enumerated,即@Enumerated(EnumType.STRING)并且您的表已经包含字符串数据(Varchar),您将收到此错误,因为。默认 EnumType 是 ORDINAL,即 EnumType.ORDINAL。

关于java.sql.SQLException : Fail to convert to internal representation Exception 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20743263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com