fixed query close in exception case using try with resource; upgraded
target java for java7 to allow try with resource