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?

24th Apr 2020, 11:15 PM
Sagar Gupta
Sagar Gupta - avatar
3 Respostas
+ 2
Sagar Gupta you're welcome. Nice to know it helped.
25th Apr 2020, 9:58 AM
Avinesh
Avinesh - avatar
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
25th Apr 2020, 7:52 AM
Avinesh
Avinesh - avatar
0
Avinesh very well explained thank you brother
25th Apr 2020, 9:51 AM
Sagar Gupta
Sagar Gupta - avatar