Mysql errorhandling

auto-reconnect if mysql server goes away, autocommit and closes cursor after data is pulled