mysql type converting and exception handling bug

make sure the  mysql type converting is done the right things. throw exception when mysql server has some error like duplicate key etc.