Thanks Oscar --- such an elegant solution - I tried it and it worked as 
expected.

Is there an option to retry DB availability - either automatically or 
through a Task etc? 


On Friday, February 7, 2020 at 2:41:42 PM UTC-6, Oscar Nalin wrote:
>
> You can configure your connection pool to ignore exceptions on creation. 
> There is a property called "ignoreExceptionOnPreLoad" which you can set to 
> "true". Then the application will start even though the database is 
> unavailable.
>
> Look under "Database" in the link below:
> https://www.dropwizard.io/en/stable/manual/configuration.html 
> <https://www.dropwizard.io/en/stable/manual/configuration.html#Database>
>
> Best regards
> Oscar Nalin
>
> Den fre 7 feb. 2020 21:22siraj <[email protected] <javascript:>> skrev:
>
>> In DW 2, I'm starting a secondary db that relies on a VPN connection. 
>>
>> Currently if VPN is unavailable DW fails to start with DB exception. 
>> What's the best approach to ignore DB availability and continue startup and 
>> optionally, try later?
>>
>> My run method
>>     @Override
>>     public void run(final AppConfiguration configuration, final 
>> Environment environment) throws Exception {
>>
>>         final Injector injector = Guice.createInjector(new 
>> ServiceModule());
>>
>>         final JdbiFactory jdbiFactory = new JdbiFactory();
>>         jdbi = jdbiFactory.build(environment, 
>> configuration.getDataSourceFactory(), "sqlserver");
>>         
>> environment.jersey().register(injector.getInstance(JumpResource.class));
>>     }
>>
>>
>> Without VPN:
>> ERROR [2020-02-07 18:35:48,409] org.apache.tomcat.jdbc.pool.
>> ConnectionPool: Unable to create initial connections of pool.
>> ! com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the 
>> host DEVSQL2, named instance sqlserver16 failed. Error: 
>> "java.net.UnknownHostException: 
>> DEVSQL2". 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:234)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(
>> SQLServerConnection.java:5963)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerConnection.
>> primaryPermissionCheck(SQLServerConnection.java:2383)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(
>> SQLServerConnection.java:2126)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(
>> SQLServerConnection.java:1993)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(
>> SQLServerConnection.java:1164)
>> ! at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver
>> .java:760)
>> ! at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(
>> PooledConnection.java:319)
>> ! at org.apache.tomcat.jdbc.pool.PooledConnection.connect(
>> PooledConnection.java:212)
>> ! at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(
>> ConnectionPool.java:744)
>> ! at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(
>> ConnectionPool.java:676)
>> ! at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:
>> 483)
>> ! at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.
>> java:154)
>> ! at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(
>> DataSourceProxy.java:118)
>> ! at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(
>> DataSourceProxy.java:107)
>> ! at io.dropwizard.db.ManagedPooledDataSource.start(
>> ManagedPooledDataSource.java:37)
>> ! at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
>> ! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
>> AbstractLifeCycle.java:72)
>> ! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(
>> ContainerLifeCycle.java:169)
>> ! at org.eclipse.jetty.server.Server.start(Server.java:407)
>> ! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(
>> ContainerLifeCycle.java:117)
>> ! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(
>> AbstractHandler.java:97)
>> ! at org.eclipse.jetty.server.Server.doStart(Server.java:371)
>> ! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
>> AbstractLifeCycle.java:72)
>> ! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
>> ! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:45)
>> ! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:87)
>> ! at io.dropwizard.cli.Cli.run(Cli.java:79)
>> ! at io.dropwizard.Application.run(Application.java:94)
>> ! at com.barone.JumpApplication.main(JumpApplication.java:28)
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "dropwizard-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dropwizard-user/a2b35316-b89c-4778-8ae6-545214b4c54a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/dropwizard-user/a2b35316-b89c-4778-8ae6-545214b4c54a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/d5f2560f-ab32-4d42-9b99-b20ba68cb5c2%40googlegroups.com.

Reply via email to