MySQL Driver?


Hello, I’m using Apache DBCP2 for a MySQL connection pool solution using BasicDataSource.

Looks like Sponge doesn’t provide a default mysql driver

Error: Database init failure: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'

Should I shade a driver in my plugin or what?


You might want to take a look at this


Yes, I’ve looked at that and it means I’ll have to write an extra MySQL class for Sponge.

Do you know why Sponge keeps SQLite driver available while MySQL driver is not available the same way?

Class.forName("org.sqlite.JDBC"); //works 
Class.forName("org.mysql.jdbc.Driver"); //doesn't work


You can find a driver here it is most likely available in maven-central as well.

EDIT: I’d also recommend taking a look at for all your connection pooling needs :slight_smile:


I decided it was easier to extend the existing class I had for Bukkit by overriding the method that set up the DataSource for the database - ended up with a new MySQL class that just a single overridden method.

I think that’s better than shading 2.1mb of unnecessary mysql driver classes into the plugin.