Please find my below query,
select nvl(max(transaction_id),0) as transaction_id from exception_details;
If I execute the above query through my jdbc code, it is giving me java.sql.SQLException: Fail to convert to internal representation
my JDBC code is as follows:
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);
}
}
}
and the data type for the column transaction_id in the table is NUMBER
varchar2; can you double-check that thetransaction_idis actually defined asnumber(I know you already said that, but still...), and that this is actually the query that's causing the error? Can you at least log/display the value ofquerybefore you execute it to verify what you're running? (It can't be exactly that anyway - the trailing semicolon would cause an error).