0
What exactly is happening here
Statement st = con.createStatement(); Con is object of connection interface and calling create statement method. Does create statement method belongs to connection class? And what is it passing to statement st? Is it passing a reference or value?
3 Respostas
+ 2
Sagar Gupta you're welcome.
Nice to know it helped.
0
The connection interface is similar to a factory and it's reference can be used to get objects of statement or preparedStatement.
con is a reference and not an object because you cannot instantiate an interface so you use that reference to create an object of Statement class.
createStatement() -> creates statement object for sending SQL statements to the database.
https://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html
0
Avinesh very well explained thank you brother