kumar jha wrote:We can register more than drvers using Class.forName("stringDriver1"), Class.forName("stringDriver2") and Class.forName("stringDriver3").
So which driver is used when we try to get a connection object, say, DriverManager.getConnection() ?
This explains itself. DriverManager#getConnection(String url)
And Welcome to JavaRanch
It lies with the DriverManager decision. It chooses the appropriate correct driver from the loaded drivers using the connection string.
Connection String usually contains the type of database it uses and DriverManger takes care of using the correct driver.