2016-03-18 11 views
0

benim Hikari veri kaynağı yapılandırması:Bilinmeyen ana istisna MS sql sürücüsü ile HikariCP yapılandırırken İşte

java.sql.SQLTransientConnectionException: springHikariCP - Connection is not available, request timed out after 1003ms. 
    at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:195) 
    at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:147) 
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:83) 
    at com.pevco.persist.reports.ReportsDaoImpl.setDataSource(ReportsDaoImpl.java:72) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.springframework.beans.BeanWrapperImpl$BeanPropertyHandler.setValue(BeanWrapperImpl.java:346) 
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:454) 
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280) 
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) 
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:835) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) 
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125) 
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) 
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109) 
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261) 
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) 
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) 
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) 
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117) 
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) 
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) 
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host "DEVWORX01, named instance DEV2014" failed. Error: "java.net.UnknownHostException: "DEVWORX01". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host. 
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(SQLServerConnection.java:3589) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck(SQLServerConnection.java:1225) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:972) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) 
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) 
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:95) 
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:101) 
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:314) 
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:171) 
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:436) 
    at com.zaxxer.hikari.pool.HikariPool.access$500(HikariPool.java:65) 
    at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:567) 
    at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:560) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host "DEVWORX01, named instance DEV2014" failed. Error: "java.net.UnknownHostException: "DEVWORX01". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.

:

<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"> 
    <property name="jdbcUrl" value="jdbc:sqlserver://" /> 
    <property name="initializationFailFast" value="false"/> 
    <property name="poolName" value="springHikariCP" /> 
     <property name="username" value="nexgen"/> 
    <property name="password" value="nexgen"/> 
    <property name="connectionTimeout" value="1000"/> 
     <property name="connectionTestQuery" value="USE NexGen;SELECT TOP 1 * FROM Transactions"/> 
    <property name="dataSourceProperties"> 
     <props> 
      <prop key="serverName">"DEVWORX01\DEV2014"</prop> 
      <prop key="databaseName">NexGen</prop> 
      <prop key="user">nexgen</prop> 
      <prop key="password">nexgen</prop> 
     </props> 
    </property> 
</bean> 

İşte

yığın izlemesi

Yukarıdaki çizgi üzerinde odaklandığım şey. Sunucu adı yerine sadece IP adresini kullanmayı denedim. Ben aynı sonucu dataSourceClassName kullanarak denedim

: aynı sonucu

<property name="dataSourceClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDataSource" /> 

Tümü. Farklı bir veri kaynağı kullanarak bağlanabiliyorum. Ben de sqlcmd kullanarak bağlanabiliyorum.

Zaten var olan birçok soruyu inceledim ve yapılandırmamın çalışması gerekiyor. How to set up datasource with Spring for HikariCP?

yanısıra hikariCP documentationimplementing hikaricp with microsoft sql server

.

Kurulumda yanlış bir şey göremiyorum. Neden bilinmeyen ana bilgisayar istisnasını alıyorum? Başka bir göz seti çok takdir edilecek.

+0

SQL Server'a SQL Studio'yu veya Excel'i veya başka bir aracı kullanarak bağlanabiliyor musunuz? Bağlantı dizesi oraya nasıl bakar? –

+0

Evet, yukarıdaki yapılandırmada kullanılan kullanıcı adını ve parolayı kullanarak SSMS ile bağlantı kurabilirim. - sqlcmd -S 192.168.16.163 \ DEV2014 -U nexgen -P nexgen -d NexGen –

+0

'u kullanarak da sqlcmd ile bağlantı kurabilirim. IP adresiyle denediyseniz, bir UnknownHostException alamazsınız. Belki bir bağlantı reddedildi ya da başka bir hata. IP adresini kullandığınızda aldığınız istisna nedir? – brettw

cevap

1

jdbcUrl'dan kurtulun. Ayrıca, ana makine adınız/örneğiniz etrafında alıntılar var, muhtemelen olmamalı. Ayrıca, aşağıdaki gibi yapılandırmayı ana bilgisayardan ayırabilirsiniz:

<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"> 
    <property name="initializationFailFast" value="false"/> 
    <property name="poolName" value="springHikariCP" /> 
    <property name="username" value="nexgen"/> 
    <property name="password" value="nexgen"/> 
    <property name="connectionTimeout" value="1000"/> 
    <property name="connectionTestQuery" value="SELECT 1"/> 
    <property name="dataSourceClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDataSource" /> 
    <property name="dataSourceProperties"> 
     <props> 
      <prop key="serverName">DEVWORX01</prop> 
      <prop key="instanceName">DEV2014</prop> 
      <prop key="databaseName">NexGen</prop> 
      <prop key="user">nexgen</prop> 
      <prop key="password">nexgen</prop> 
     </props> 
    </property> 
</bean> 
+0

jdbcUrl ile göz ardı edildiğini bildiriyordum. Bu yüzden uyarıya inandım. Evet, burada listelenen şekilde ayarlandı. TYVM! –