Thain century in vain as Essex target of 317 is not enough