title: Error using com.zaxxer.hikari.HikariDataSource
body: <p>I'm facing an error integrating HikariCP with Spring's JdbcTemplate.
  I'm using Spring 3.2.2, HikariCP 2.3.8 and sybase jconn4 version 7.0.0</p>
  
  <p>Spring configuration :</p>
  
  <pre><code>&lt;bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"&gt;
      &lt;property name="dataSourceClassName" value="com.sybase.jdbc4.jdbc.SybDataSource" /&gt;
  
      &lt;property name="connectionTestQuery" value="SELECT 1" /&gt;
      &lt;property name="maximumPoolSize" value="100" /&gt;
      &lt;property name="idleTimeout" value="60000" /&gt;
      &lt;property name="jdbcUrl"
          value="jdbc:sybase:Tds:${hostname}:${port}/${dbname}" /&gt;
      &lt;property name="username" value="${username}" /&gt;
      &lt;property name="password" value="${password}" /&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="ds" class="com.zaxxer.hikari.HikariDataSource"
      destroy-method="close"&gt;
      &lt;constructor-arg ref="hikariConfig" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
      &lt;property name="dataSource"&gt;
          &lt;ref bean="ds" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Every time the context is loading it throws this error and the datasource can't be created</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds' defined in class path resource [commons/config/datasourceTest.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.zaxxer.hikari.HikariDataSource]: Constructor threw exception; nested exception is com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
      at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
      at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
      at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
      at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
      ... 25 more
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.zaxxer.hikari.HikariDataSource]: Constructor threw exception; nested exception is com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
      ... 42 more
  Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
      at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:544)
      at com.zaxxer.hikari.pool.BaseHikariPool.&lt;init&gt;(BaseHikariPool.java:171)
      at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:60)
      at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:48)
      at com.zaxxer.hikari.HikariDataSource.&lt;init&gt;(HikariDataSource.java:80)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
      ... 44 more
  Caused by: java.sql.SQLException: JZ0PN: Specified port number of -1 was out of range. Port numbers must meet the following conditions: 0 &lt;= portNumber &lt;= 65535
      at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybConnection.handleSQLE(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybConnection.a(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybConnection.handleHAFailover(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybConnection.&lt;init&gt;(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybDriver.createConnection(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybDriver.connect(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybDriver.connect(Unknown Source)
      at com.sybase.jdbc4.jdbc.SybDataSource.getConnection(Unknown Source)
      at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:438)
      at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542)
      ... 53 more
  </code></pre>
  
  <p>Now the interesting part is this is working perfectly if i do it with simple code.</p>
  
  <pre><code>public class JdbcTemplateFactoryTest {
  
      @Autowired
      HikariConfig hikariConfig;
  
      //@Autowired
      //HikariDataSource ds;
  
  
      @Test
      public void hikaritest(){
  
          HikariDataSource ds = new HikariDataSource(hikariConfig);
          JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
  
          assertNotNull(jdbcTemplate);
      }
  }
  </code></pre>
  
  <p>Strange part is if i uncomment the <strong>ds</strong> to load by spring) it fails.</p>
  
  <p>Spent the whole day on this. Any suggestion is appreciate</p>