Bug 68436 - Hide "Not loading a JDBC driver as driverClassName property is null" warning
Summary: Hide "Not loading a JDBC driver as driverClassName property is null" warning
Status: NEW
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-02 11:35 UTC by Mailmur
Modified: 2024-01-03 14:57 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mailmur 2024-01-02 11:35:51 UTC
Unnecessary warning fills up the webapp logging file, this happens every time a db pool creates a new connection and no classname is given.
>> Not loading a JDBC driver as driverClassName property is null.

Using the same webapp for mysqljar and mariadbjar system may use a configuration without driverClassName field. Destination tomcat may provide both or one of jdbc jar files without a webapp developer knowledge.

What is an empty driverClassName="" attribute was given then it's an explicit choice and Tomcat did not need to write a warning log?

See source code:
https://github.com/apache/tomcat/blob/ed8cc4f3beddbdc7d9634cc287660322804007fd/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java#L292

if (poolProperties.getDriverClassName()==null) {
  //rely on DriverManager
  log.warn("Not loading a JDBC driver as driverClassName property is null.");
} else {...

See contextxml db connection example:
<!-- use mariajdbc if found then mysqljdbc -->
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
  initialSize="2" maxActive="300" maxIdle="10" maxWait="30000"
  username="myuser" password="mypwd"
  url="jdbc:mysql://127.0.0.1:3306/mydb?permitMysqlScheme&amp;useUnicode=true&amp;characterEncoding=utf8"
  validationQuery="SELECT 1" validationInterval="6000" validationQueryTimeout="10"
  rollbackOnReturn="true" removeAbandoned="true" removeAbandonedTimeout="14400" logAbandoned="false"
  testOnBorrow="true" maxAge="300000" timeBetweenEvictionRunsMillis="60000"
  defaultTransactionIsolation="READ_COMMITTED"
/>
Comment 1 Mark Thomas 2024-01-02 12:04:06 UTC
Correcting product
Comment 2 Christopher Schultz 2024-01-03 14:57:39 UTC
Seems easy enough to (a) change this into a DEBUG log and (b) change the language to be more clear. It's not that the driver isn't being loaded... it's that the pool isn't *explicitly* triggering the loading of the driver class. If I saw that WARNING in the log, I would wonder how my application was able to connect to the database if the pool wasn't loading the driver...