I was working with multiple database drivers (Oracle, PostgreSql) yesterday and java.sql.DriverManager struck me as strange.
- You can register a driver with the DriverManager.
- You can interrogate the DriverManger for a driver that handles a database URL.
- However when you request for a connection, DriverManager will walk through the drivers that it knows about and attempt to connect to the database. So if you happened to have your credentials incorrect for one of the URL, DriverManager would quietly move on to attempt to use another driver. So I ended up getting another driver to connect to PostgreSql. Why does it not use the
How to debug this? You can't! But you can add a line in your code
and see what the manager is doing.
I attended a session at QConSF 2010 about broken abstraction and it occurred to me that any API is really an abstraction. Is this a broken abstraction?