Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
    Bookmark Topic Watch Topic
  • New Topic

Connection is interface so how can we access it createStatement() on connection objec

 
Ami Ambre
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Report post to moderator
But Connection is a interface & so how can we access it

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc dbc:student");

Statement st = con.createStatement();
Creates a Statement object for sending SQL statements to the database
ReturnType of createStatement() is Statement
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Report post to moderator
belongs in Beginner's forum.

Connection is an interface, but DriverManager.getConnection() returns an object which implements this interface. Interface is only telling you what methods that implementation object will have.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34378
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question in multiple forums. It makes answers harder to follow and wastes people's time answering the same question. I'll close this copy and we can continue discussion in the JDBC thread.
 
    Bookmark Topic Watch Topic
  • New Topic