Fix data base exception and illegal state exception.