title: Define access to an Oracle database with TNS on a application.yml
body: <p>I would define the access to my Oracle database on a application.yml</p>
  
  <p>I succeed to make a connection with code like <a href="https://stackoverflow.com/questions/19536162/how-to-connect-jdbc-to-tns-oracle">this</a> where it's define in a main class.</p>
  
  <pre><code>System.setProperty("oracle.net.tns_admin","MyOracleHome/NETWORK/ADMIN");
  Class.forName("oracle.jdbc.OracleDriver");
  Connection c = DriverManager.getConnection("jdbc:oracle:thin@tnsName","username","password");
  </code></pre>
  
  <p>I wish do the same thing with application.yml
  I tried with :  </p>
  
  <pre><code>oracle:
    net:
      tns_admin: MyOracleHome/NETWORK/ADMIN
  spring:
    datasource:
      url: jdbc:oracle:thin:@tnsName
      username: username
      password: password
      driverClassName: oracle.jdbc.driver.OracleDriver
  </code></pre>
  
  <p>with a Main class :</p>
  
  <pre><code>@SpringBootApplication
  public class MonApplication{
    public static void main(String[] args)  {
      SpringApplication.run(MonApplication.class, args);
    }
  }
  </code></pre>
  
  <p>Launching MonApplication, I obtained :</p>
  
  <pre><code>2018-12-28 16:25:56 [restartedMain] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool - Exception during pool initialization.
  java.sql.SQLRecoverableException: Erreur d'E/S: Unknown host specified 
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:536) (....)
  
  Caused by: oracle.net.ns.NetException: Unknown host specified 
  at oracle.net.resolver.HostnameNamingAdapter.resolve(HostnameNamingAdapter.java:191) (....)
  2018-12-28 16:25:56 [restartedMain] WARN  o.h.e.j.e.i.JdbcEnvironmentInitiator - HHH000342: Could not obtain connection to query metadata : Erreur d'E/S: Unknown host specified 
  2018-12-28 16:25:56 [restartedMain] INFO  org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.spatial.dialect.postgis.PostgisPG9Dialect
  2018-12-28 16:25:56 [restartedMain] INFO  org.hibernate.type.BasicTypeRegistry - HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@4adc41d4
  2018-12-28 16:25:56 [restartedMain] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool - Starting...
  2018-12-28 16:25:57 [restartedMain] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool - Exception during pool initialization.
  java.sql.SQLRecoverableException: Erreur d'E/S: Unknown host specified 
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:536) (....)
  
  Caused by: oracle.net.ns.NetException: Unknown host specified 
  at oracle.net.resolver.HostnameNamingAdapter.resolve(HostnameNamingAdapter.java:191) (...)  
  2018-12-28 16:25:57 [restartedMain] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 17002, SQLState: 08006
  2018-12-28 16:25:57 [restartedMain] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Erreur d'E/S: Unknown host specified 
  2018-12-28 16:25:57 [restartedMain] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
  2018-12-28 16:25:57 [restartedMain] INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat]
  2018-12-28 16:25:57 [restartedMain] INFO  o.s.b.a.l.ConditionEvaluationReportLoggingListener - 
  
  Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2018-12-28 16:25:57 [restartedMain] ERROR o.s.boot.SpringApplication - Application run failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
  (....) 
  Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402)
  (....)
  Caused by: org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
  at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115)
  (....)
  Caused by: java.sql.SQLRecoverableException: Erreur d'E/S: Unknown host specified 
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:536)(....)
  Caused by: oracle.net.ns.NetException: Unknown host specified 
  at oracle.net.resolver.HostnameNamingAdapter.resolve(HostnameNamingAdapter.java:191)
  (....)
  </code></pre>
  
  <p>I think the problem comes from the syntax but I didn't find example of what I want.</p>