sqlite bug fix

This commit is contained in:
dcollin 2015-12-04 10:10:56 +01:00 committed by Daniel Collin
parent 89d8834d80
commit d3ba64477b

View file

@ -216,40 +216,40 @@ public class DBConnection implements Closeable{
public static <T> T exec(PreparedStatement stmt, SQLResultHandler<T> handler) throws SQLException{ public static <T> T exec(PreparedStatement stmt, SQLResultHandler<T> handler) throws SQLException{
try{ try{
// Execute // Execute
stmt.execute(); boolean isResultSet = stmt.execute();
// Handle result // Handle result
if( handler != null ){ if( handler != null ){
ResultSet result = null; ResultSet result = null;
try{ try{
if(stmt.getMoreResults()){ if(isResultSet){
result = stmt.getResultSet(); result = stmt.getResultSet();
return handler.handleQueryResult(stmt, result); return handler.handleQueryResult(stmt, result);
} }
else else
return null; return null;
}catch(SQLException sqlex){ }catch(SQLException sqlex){
logger.throwing(null, null, sqlex); logger.log(Level.WARNING, null, sqlex);
}finally{ }finally{
if(result != null){ if(result != null){
try { try {
result.close(); result.close();
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
logger.throwing(null, null, sqlex); logger.log(Level.WARNING, null, sqlex);
} }
result = null; result = null;
} }
} }
} }
}catch(SQLException sqlex){ }catch(SQLException sqlex){
logger.throwing(null, null, sqlex); logger.log(Level.WARNING, null, sqlex);
// Cleanup // Cleanup
} finally { } finally {
if (stmt != null) { if (stmt != null) {
try { try {
stmt.close(); stmt.close();
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
logger.throwing(null, null, sqlex); logger.log(Level.WARNING, null, sqlex);
} }
stmt = null; stmt = null;
} }