title: JDBC in JAVA MysqlDataSource
body: <p>Im working on JDBC and using MySqlDataSource to connect. How do i create a schema before adding the schema name in DataSource.setDataBaseName()?? connection is ok and i can execute updates and so on, but only if i manually create Schema/database in MysqlWorkbench</p>
  
  <pre><code>import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
  
  import javax.sql.DataSource;
  import java.sql.Connection;
  import java.sql.SQLException;
  
  public class DBHandler {
  
  private String user = "root";
  private String serverName = "localhost";
  private String dbName = "TimeEdit";
  private Connection connection;
  private MysqlDataSource datasource = new MysqlDataSource();
  
  public DBHandler(String passw) throws SQLException {
      datasource.setPassword(passw);
      datasource.setUser(user);
      datasource.setServerName(serverName);
      datasource.setDatabaseName(dbName);
      //datasource.setURL("jdbc:mysql://&lt;localhost&gt;:&lt;3306&gt;/");
  
  }
  
  public Connection getConnection() throws SQLException {
      return datasource.getConnection();
  }
  </code></pre>