implement prepared stmt recovery mechanism

fixes issue #150 (Prepared statement are broken after sqlite error)