title: connecting to mysql datasource in spring boot without xml
body: <p>Im using some examples from the book Spring In Action 4.</p>
  
  <pre><code>@Bean
  public DataSource dataSource() {
      return new EmbeddedDatabaseBuilder()
              .setType(EmbeddedDatabaseType.H2)
              .addScript("thetenticle.sql")
              .build();
  }
  
  @Bean
  public JdbcOperations jdbcTemplate(DataSource dataSource) {
      return new JdbcTemplate(dataSource);
  }
  </code></pre>
  
  <p>The example creates a datasource which can be used to perform db operations. the example uses an embedded h2 database. this is no use to me as i want to connect to a mysql database remotely. i was hoping i could just wire in a DataSource object that has the connection details for my database. Is there a way i could do this. I dont have any interest in hibernate or xml config. im using spring boot. </p>
  
  <p>Ive spent the last 18 hours trying to find a simple example that creates a mysql data source instead of an embedded h2 and sends a query to the database. i haven't found a single example of this yet. some sites suggest addingthe connection details to application.properties....but how can i create a datasource from this that i can make sql queries against?</p>
  
  <p>sorry for my ignorance but i just need a simple explaination</p>