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

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -