use sql connection function without in loop
reconnect if connect fail