Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to fail fast on bad DB password #32

Closed
mbucc opened this issue Feb 3, 2014 · 4 comments
Closed

Question: how to fail fast on bad DB password #32

mbucc opened this issue Feb 3, 2014 · 4 comments
Labels

Comments

@mbucc
Copy link

mbucc commented Feb 3, 2014

Hi,
If my HikariCP config has the wrong database credentials, I'd like my server to fail fast.

Seems like the only way is to wait for acquireRetries * acquireRetryDelay milliseconds, then try to call getConnection(), catch the SQLException and then exit.

Do I have that right?

Thanks,
Mark

@brettwooldridge
Copy link
Owner

That is correct.

Sent from my iPhone

On Feb 4, 2014, at 8:22 AM, mbucc notifications@github.com wrote:

Hi,
If my HikariCP config has the wrong database credentials, I'd like my server to fail fast.

Seems like the only way is to wait for the acquireRetries * acquireRetryDelay milliseconds, then try to call getConnection(), catch the SQLException and then exit.

Do I have that right?

Thanks,
Mark


Reply to this email directly or view it on GitHub.

@brettwooldridge
Copy link
Owner

I'll investigate a way to fail the pool fast. Likely it will be via a RuntimeException thrown from the constructor ... but will require that the minimum pool size is non-zero.

@zimmi
Copy link

zimmi commented Feb 4, 2014

If you instantiate your DataSource programmatically, you could use the raw driver DataSource to do the getConnection() check. e.g.:

PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser("username");
dataSource.setPassword("password");

// check raw data source, e.g. dataSource.getConnection();

HikariConfig config = new HikariConfig();
config.setDataSource(dataSource);

HikariDataSource connectionPool = new HikariDataSource(config);

But I guess that won't help if you do this the declarative way.

@brettwooldridge
Copy link
Owner

The recently released HikariCP 1.2.9 has a new property initializationFailFast that is not yet documented. If you set this to true, there will be a RuntimeException thrown when a HikariDataSource is constructed, providing that the minimumPoolSize is > 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants