r/SpringBoot • u/xjwj • Feb 05 '26
Question Anyone have experience adding a custom class loader to load JDBC drivers dynamically?
Pretty much what the title says – has anyone had success/experience creating a custom class loader to load a JDBC driver? Most of the literature I've come across talks about modifying the class path on startup or otherwise having a local JAR file, but in my case I want to store drivers themselves elsewhere (in a database) and be able to dynamically load them.
I played around with some test code today and made a custom class loader that can load arbitrary bytes, but I'm still getting an error when I go to actually use the class. It "feels" like the low-level DriverManager is only aware of what it sees on launch. Any thoughts appreciated!
View all comments
Show parent comment
1
u/xjwj Feb 05 '26
The system needs to be able to connect to data sources for which the driver isn’t known ahead of time and the system can’t just be restarted.