title: How to execute custom code before new connection is created from datasource
body: <p>I need to execute custom code before new connection is created in data source. I am using BasicDataSource for connection pooling. I am using Spring jdbcTemplate with BasicDataSource so I am not calling getConnection() manually.</p>
  <p>I need to execute custom code before connection in order to re-login with kerberos credential for hive jdbc.</p>
  <p>Is it possible to do something like this?</p>
  <p>I am creating connection with below sample code</p>
  <pre><code>@Bean
  public DataSource dataSource() {
  
      BasicDataSource dataSource = new BasicDataSource();
      dataSource.setUrl(url);
      dataSource.setUsername(userName);
      dataSource.setPassword(password);
      dataSource.setDriverClassName(driverClass)
  
      return dataSource;
  }
  </code></pre>
  <p>thanks</p>