• 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

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am a having one doubt while making a connection to a database.

********************************************
// Variables or reference
Connection con=null;
Statement stmt=null;
ResultSet rs=null;

//Db connection
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:abc");
stmt=con.createStatement();
rs=stmt.executeQuery("Select * from <table>");

****************************************************

In this,Connection,Statement and resultset are all interfaces.And moreover,the methods such as createStatement(),executeQuery() are all empty only in Connection Interface and Statement Interface respectively.

Being a method which is defined in interfaces are empty or abstract by default,

if that is the case ,How can we use these here.
(createStatement(),executeQuery())?

Where and all the implementation of these methods..


Pls explain these....

Warm Regards,
Senthan.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Senthan,

Implementation's for these interface are found in runtime library (rt.jar in jre/lib).

essentialy loads this library.

This is beauty of programing to interface. This way your code is independent of database. you can substitude with driver for any database.

Regards,
Raja.
reply
    Bookmark Topic Watch Topic
  • New Topic