aspose file tools*
The moose likes JDBC and the fly likes JDBC Driver / Specification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Driver / Specification" Watch "JDBC Driver / Specification" New topic
Author

JDBC Driver / Specification

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
I have made the assumption that when an application makes a call to DriverManager.getConnection, that the DriverManager would call acceptsURL on all of its registered drivers (java.sql.Driver implementations). This assumption appears to be false, as my observed behaviour is that a call to connect is made before anything, and then no other calls to the Driver are made.

So I ask, why is this so? Would a correct Driver implementation call acceptsURL from its connect method? i.e.



This seems like an odd thing to do, hence my speculation that I am misunderstanding something. I originally guessed that the DriverManager was acting this way because only one Driver implementation was registered - I then went on to register two Driver implementations and observed the same behaviour. The following test case only registers one Driver implementation so that it is reproducable without any additional drivers. It requires a J2SE 1.2 or 1.3 compiler (a little bit of work would need to be done to get it to compile with 1.4 due to the additions to the JDBC API).

The observed output is:


I was expecting:


The test case involves three source files and can be executed with:



The three source files follow:







[ July 25, 2004: Message edited by: Tony Morris ]

[ July 25, 2004: Message edited by: Tony Morris ]
[ July 25, 2004: Message edited by: Tony Morris ]

Tony Morris
Java Q&A (FAQ, Trivia)
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
I believe I have just found my answer:


When the DriverManager is trying to establish a connection, it calls that driver´┐Żs
connect method and passes the driver the URL. If the Driver implementation
understands the URL, it will return a Connection object; otherwise it returns null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Driver / Specification