java - createStatement method in jdbc -
i have learned connection interface , can define method definition in interface. how work:
....
statement stmt = con.createstatement();
....
how method create statement object , return it?
because concrete implementation of connection
interface been returned when called getconnection()
. interface definies method signatures. concrete implementation contains method implementations.
connection connection = drivermanager.getconnection(url, username, password); system.out.println(connection.getclass().getname()); // that's name of concrete implementation.
it's jdbc driver contains concrete implementations. jdbc api enables write java code independent of specific database server used. whenever switch of db, have switch jdbc driver (and possibly change sql statements whenever contain db-server specific sql language, not java code).
Comments
Post a Comment