我遇到需要从MySQL数据库中获取结果集的情况。但问题是,当我使用prep / callable语句时,我没有获得结果集,但是当通过toad或phpmyadmin运行相同的sql查询时,它会在控制台上给出正确和预期的结果。代码如下: -
Connection connection = null;
CallableStatement cstmt = null;
String mappedEVentIds = "";
try {
connection = CreateDBConnection.createDBConn();
cstmt = connection.prepareCall("select metaEventId from metatologtable where metatologtable.baseEventId in (select `metatologtable`.baseEventId from metatologtable inner join logtable on logtable.baseEventId = metatologtable.baseEventId where metatologtable.metaEventId In"+metaEventIds+")");
ResultSet rs = cstmt.executeQuery();
while(rs.next()){
mappedEVentIds = mappedEVentIds+rs.getString("metaEventId");
}
return mappedEVentIds;
}
catch(Exception e){
}
finally{
closeConnection(connection, cstmt);
}
它没有抛出任何错误,但是结果集为空,并且在(rs.next)阻止时没有进入