r/SpringBoot • • 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!

11 Upvotes

8 comments sorted by

View all comments

Show parent comment

3

u/Sheldor5 Feb 06 '26

JDBC drivers are loaded via SPIs so I don't know if a classloader alone even works

good luck