The code below shows the database interaction.
Actually I want to know is there a way to get/import the driver class from a jar file instead of writing Class.forName(driverDetails)? I was asked this question by one of my superiors.
You don't need that line of code at all.
This method of loading the driver class explicitly was deprecated a long time back - like a decade ago.
If the driver JAR contains a driver service entry under its META-INF/services/, the driver class gets loaded automatically by class loader.
Have a look at DriverManager's javadoc for an explanation.