• 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

Internal technique about initialize Connection Interface in JDBC

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In one of the interview faced by me recently, an interviewer asked me Connection Interface of JDBC is a Interface and we cant make the object of interface the how we initialize the object of connection using DriverManager Class like this
Ex:-


Please explain me the answer of the above question...
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

we can't make an object of an interface, but we can create an object of a class that implements this interface.
You can find an explanation how DriverManager.getConnection works in the JDBC specyfication:
http://jcp.org/aboutJava/communityprocess/final/jsr221/index.html

getConnection — the method the JDBC client invokes to establish a connection.
The invocation includes a JDBC URL, which the DriverManager passes to each
driver in its list until it finds one whose Driver.connect method recognizes the
URL. That driver returns a Connection object to the DriverManager, which in
turn passes it to the application.


DriverManager just passes the URL to each registered driver, if one driver accepts the url, then this driver creates a connection object
(that implements Connection interface) and returns this object to the driver manager.

 
reply
    Bookmark Topic Watch Topic
  • New Topic