Improving SQL Connection handling
Error codes shoould be 'long'