Prepare method to collect stmt and set up locks