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
2
u/xjwj Feb 05 '26
I’d be happy if I could just load in an arbitrary driver and allow connections to it, don’t need to solve updates or unloading at this point in time. It’s to allow connections to tertiary data sources in our SaaS solution without having to include the drivers in the core service.