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

NullPointerException #81

Closed
Emperor88 opened this issue May 16, 2014 · 5 comments
Closed

NullPointerException #81

Emperor88 opened this issue May 16, 2014 · 5 comments
Assignees
Labels

Comments

@Emperor88
Copy link

This exception gets thrown on quite frequently:
Exception in thread "Thread-20" java.lang.RuntimeException: java.lang.NullPointerException
at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:106)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.abortInternal(ConnectionImpl.java:1229)
at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:104)

I'm configuring HikariCP like this:
HikariConfig config = new HikariConfig();
config.setMinimumPoolSize(1);
config.setMaximumPoolSize(3);
config.setInitializationFailFast(true);
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setJdbcUrl("jdbc:mysql://" + URL);
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
config.setJdbc4ConnectionTest(true);
pool = new HikariDataSource(config);

Changing idle timeout value seems to influence the exception being thrown (but doesn't stop it from happening).
I'm probably doing something wrong, as I couldn't find simular problems when searching on google.

@brettwooldridge
Copy link
Owner

This thread indicates that it is a bug with the MySQL JDBC driver implementation of the Connection.isValid() method -- which is what HikariCP uses by default. I would recommend two things: first, make sure you are using the latest MySQL Connector/J version, and second change HikariCP to use query-based connection testing like this:

config.setJdbc4ConnectionTest(false);
config.setConnectionTestQuery("/* ping */ SELECT 1");

@Emperor88
Copy link
Author

Thanks for the quick reply, updating the MySQL connector did the trick.

@MMuzaffar
Copy link

MMuzaffar commented Jul 13, 2019

What Connector version you are using now?

@MMuzaffar
Copy link

I replaced com.mysql.jdbc_5.1.5.jar file with mysql-connector-java-8.0.11.jar in \WebContent\WEB-INF\lib folder and these exceptions gone.

@MMuzaffar
Copy link

This thread indicates that it is a bug with the MySQL JDBC driver implementation of the Connection.isValid() method -- which is what HikariCP uses by default. I would recommend two things: first, make sure you are using the latest MySQL Connector/J version, and second change HikariCP to use query-based connection testing like this:

config.setJdbc4ConnectionTest(false);
config.setConnectionTestQuery("/* ping */ SELECT 1");

I don't know where are these configs?

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