title: How to generate a lot of unique random strings in Scala
body: <p>I want to generate a lot of random strings that unique of each other and unique in MySQL with specify the number of generated like 10,000.</p>
  
  <p>I could make sure the strings are unique each other in every time generated strings, just check if the <code>List[String]</code> contains the string in each time generate.<br>
  But I don't know how to make sure its unique in MySQL, I have been set the unique index in MySQL like
  <code>
  ALTER TABLE Code ADD UNIQUE INDEX `codeUnique` (`code`);
  </code></p>
  
  <p>But if the unique guarantee is when inserting data into MySQL, insert will failure.<br>
  And if check the insert failure in each time insert, generating will take  a very very long time when the number of generated is large.</p>