refactored the connections in EntityDatabase against the PreparedStatement and ResultSet leak