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/bikeram Feb 05 '26
Oh that should be easy. Mark them as provided in your maven build then put them on your class path when you deploy.
Edit: saw your other reply. same thing, just implement a class loader for your jars.