title: create mysql database with username and password from java code
body: <p>How to create mysql database with username and password from java code ?
  and create all the tables ?</p>
  
  <p>i was googling and i found this code </p>
  
  <pre><code>Conn = DriverManager.getConnection
  ("jdbc:mysql://localhost/?user=root&amp;password=rootpassword"); 
  s=Conn.createStatement();
  int Result=s.executeUpdate("CREATE DATABASE databasename");
  </code></pre>
  
  <p>but in my case i need to :</p>
  
  <p>-set a  username and password from java</p>
  
  <ul>
  <li>create all the tables</li>
  </ul>
  
  <p>make sure that:</p>
  
  <ul>
  <li><p>MySQL charset: UTF-8 Unicode (utf8)</p></li>
  <li><p>MySQL connection collation: utf8_general_ci</p></li>
  <li><p>my database and table collations are set to: utf8_general_ci or utf8_unicode_ci</p></li>
  </ul>
  
  <p>and after that i must execute this in mysql :
   SET NAMES 'utf8'</p>
  
  <p>SET CHARACTER SET utf8</p>
  
  <p>can i do that on java code ?</p>