There is where the Database Drivers comes into place.
Now all database should support common operations of executing a query, trversion through the resultset, reading each column in a result, getting a connection,closing a connection ...etc.
So these standard operations are made as interface methods by
Java.
Now the vendors who provide database drivers, implement this interface and hence they have to write their own implementation for each methods.
Say Oracle database driver will have its own logic/code of executing a query.
an SQL Server database driver will have its own logic/code for the same purpose.
Since both implement the Statement interface, we the developers need not worry what method to call if its a oracle driver or sql server driver.
we just call the method in the interface, and based upon the driver that is loaded, those methods are called and executed.
In that way, Java allows any database vendor to write their drivers but all drivers will be in a standard way ,without confusing the developer.