• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC Driver / Specification

 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic