*Check null before close.
*Close result set first.
*Close Statement second.
https://issues.jboss.org/browse/JBAS-5303
https://community.jboss.org/thread/92980?tstart=0&_sscc=t
java.sql.SQLException: Exhausted ResultSet
public String getCxAANo(String rr, String bb) {
String returnCode = "";
ResultSet rst = null;
Statement stm = null;
ResultSet rstSimTbl = null;
PreparedStatement stmSimTbl = null;
try {
stm = objDBCon.createStatement();
rst = stm.executeQuery("select distinct(XXX) from AAA where QQ_NO='" + qqNo+ "'");
if (rst != null) {
while (rst.next()) {
simVal = rst.getString("XX");
count++;
}
}
if (count == 0) {
returnCode = "NODATA";
} else if (count == 1) {
stmSimTbl = objDBCon.prepareStatement("select count(*) from BBB_CONFIG where XX_NO=? and DD_CODE=?");
stmSimTbl.setString(1, XXVal);
stmSimTbl.setString(2,DD_code);
rstSimTbl = stmSimTbl.executeQuery();
if (rstSimTbl != null) {
while (rstSimTbl.next()) {
simCount = rstSimTbl.getInt(1);
}
}
if (simCount == 1) {
returnCode = "ALLOWED";
} else {
returnCode = "RESTRICTED";
}
}
} catch (Exception er) {
returnCode = "ERROR";
} finally {
try {
if (rstSimTbl != null) {
rstSimTbl.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (stmSimTbl != null) {
stmSimTbl.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (rst != null) {
rst.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (stm != null) {
stm.close();
}
} catch (Exception ex) {
ex.getMessage();
}
}
return returnCode;
}
Answer 5:
http://stackoverflow.com/questions/3502005/java-sql-sqlexception-exhausted-resultset
java.sql.SQLException: Exhausted ResultSet
public String getCxAANo(String rr, String bb) {
String returnCode = "";
ResultSet rst = null;
Statement stm = null;
ResultSet rstSimTbl = null;
PreparedStatement stmSimTbl = null;
try {
stm = objDBCon.createStatement();
rst = stm.executeQuery("select distinct(XXX) from AAA where QQ_NO='" + qqNo+ "'");
if (rst != null) {
while (rst.next()) {
simVal = rst.getString("XX");
count++;
}
}
if (count == 0) {
returnCode = "NODATA";
} else if (count == 1) {
stmSimTbl = objDBCon.prepareStatement("select count(*) from BBB_CONFIG where XX_NO=? and DD_CODE=?");
stmSimTbl.setString(1, XXVal);
stmSimTbl.setString(2,DD_code);
rstSimTbl = stmSimTbl.executeQuery();
if (rstSimTbl != null) {
while (rstSimTbl.next()) {
simCount = rstSimTbl.getInt(1);
}
}
if (simCount == 1) {
returnCode = "ALLOWED";
} else {
returnCode = "RESTRICTED";
}
}
} catch (Exception er) {
returnCode = "ERROR";
} finally {
try {
if (rstSimTbl != null) {
rstSimTbl.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (stmSimTbl != null) {
stmSimTbl.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (rst != null) {
rst.close();
}
} catch (Exception ex) {
ex.getMessage();
}
try {
if (stm != null) {
stm.close();
}
} catch (Exception ex) {
ex.getMessage();
}
}
return returnCode;
}
Answer 5:
http://stackoverflow.com/questions/3502005/java-sql-sqlexception-exhausted-resultset
No comments:
Post a Comment