adding mysql resource handling