Interface/abstract module syntax
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amelia_Pang
Posted On:   Friday, May 4, 2001 02:18 AM

Need to ask a question on interfaces. You see there is the following codes: .... .... Ora_DBAccess db = new Ora_DBAcess( ); ..../*if connected to database....*/ Connection cx = db.cx; String sql = '.......'; try { PreparedStatement pstmt = cx.prepareStatement(sql); .... Resultset rset = pstmt.executeQuery(); ......} Although I know that prepareStatement sends the sql to database for precompilation and stores the compiled sql in pstmt, but what I do not understand is the syntax part of "PreparedStatement pstmt = cx.prepareStatement(sql);" What is the underlying concept for the syntax of the above state   More>>

Need to ask a question on interfaces.

You see there is the following codes:
....
....
Ora_DBAccess db = new Ora_DBAcess( );
..../*if connected to database....*/
Connection cx = db.cx;

String sql = '.......';
try
{
PreparedStatement pstmt =
cx.prepareStatement(sql);
....
Resultset rset = pstmt.executeQuery();
......}

Although I know that prepareStatement sends the sql to database for precompilation and stores the compiled sql in pstmt, but what I do not understand is the syntax part of
"PreparedStatement pstmt = cx.prepareStatement(sql);"

What is the underlying concept for the syntax of the above statement?
Why is there a dot between the object cx and the prepareStatement(sql) which is an abstract module of the interface PreparedStatement?

In what other cases does such a syntax apply?




Appreciate your explanation. Thanks.

   <<Less

Re: Interface/abstract module syntax

Posted By:   Venkat_r  
Posted On:   Friday, May 4, 2001 07:33 AM

PreparedStatement is an Inteface and you can not directly say
PreparedStatemet pstmt=new PreparedSattement(sql);
The statement cx.prepareStatement(sql) will give an object with
knows how to execute the abstract methods in the Interface.

another point to note is that much of the information intially needed
to create PreparedStament is provided by the Connection object
cx..

regards..
About | Sitemap | Contact