MyBatis database connection pool will throw a null pointer exception if the driver class is not configured

17 views
Skip to first unread message

Jackie Gu

unread,
May 18, 2021, 12:01:49 AM5/18/21
to mybatis-user
UnpooledDataSource class initializeDriver method, if a member variable "driver" is null, then the "registeredDrivers.containsKey(driver)" code will throw null pointer exception,  When the DefaultSqlSession's method catches the exception, the exception thrown has been modified to "Error querying database".

M Huzaifah

unread,
May 19, 2021, 10:07:13 AM5/19/21
to mybati...@googlegroups.com
Hi,

Then configure you driver class. How come you want to connect to database without knowing you database system that you use. I dont get your point. The driver class should be required when you try to connect to database.

Regards

Pada tanggal Sel, 18 Mei 2021 11.01 AM Jackie Gu <jack...@gmail.com menulis:
UnpooledDataSource class initializeDriver method, if a member variable "driver" is null, then the "registeredDrivers.containsKey(driver)" code will throw null pointer exception,  When the DefaultSqlSession's method catches the exception, the exception thrown has been modified to "Error querying database".

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/a85ab528-5a52-46af-87fb-74fafb4ad8e4n%40googlegroups.com.

Jackie Gu

unread,
May 24, 2021, 11:13:17 AM5/24/21
to mybati...@googlegroups.com
Hi,
I mean Is driver class can be set to the optional configuration items, because the JDK DriverManager when to get the datasource connection, automatically traverses the registered through SPI mechanisms driver classes, such as: MySQL's com.mysql.cj.jdbc.Driver. This is already happening in Spring JPA.And while DriverManger would have thrown a correct exception if the driver class had been incorrectly configured, it is now throwing an exception that can mislead the lookup problem.

M Huzaifah <mhuzaif...@gmail.com> 于2021年5月19日周三 下午10:07写道:
You received this message because you are subscribed to a topic in the Google Groups "mybatis-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mybatis-user/D1PQSwxUvvA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CA%2B0qJZt%3DxVLkTeJMV6FZJyBA43o3yeKQUDxsmVP0_0ESnxDbKQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages