title: Configure DataSource programmatically in Spring Boot
body: <p>With Spring Boot I can instantiate a <code>JdbcTemplate</code> with the following:</p>
  
  <p>Code:</p>
  
  <pre><code>@Autowired
  private JdbcTemplate jdbcTemplate;
  </code></pre>
  
  <p>Properties:</p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://my_url:my_port/my_other_stuff
  spring.datasource.username=my_user_name
  spring.datasource.password=my_password
  spring.datasource.driver-class-name=org.postgresql.Driver
  </code></pre>
  
  <p>This create a DataSource of class: <code>org.apache.tomcat.jdbc.pool.DataSource</code></p>
  
  <p>How do I set the DataSource username/password programmatically? </p>
  
  <p>We have a policy not to store credentials in plain text and I have to use a specific credential provider where I work.</p>