0

What does this mean ? Statement st=con.CreateStatement(); how method of Statement interface is accessed by Connection interface reference con ? please help me to understand the concept...

4
Contributors
6
Replies
34
Views
2 Years
Discussion Span
Last Post by JamesCherrill
0

are you talking about createStatement ?
this is a method from the Connection interface, returning a Statement.
just check here .

EDIT: the Statement interface doesn't have a createStatement method, by the way. if you check the api, you'll see this:

See Also:
Connection.createStatement(), ResultSet

which is basicly telling: the createStatement method of the Connection interface is related to the Statement interface. it's not part of it, though.

Edited by stultuske

2
try {
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    while (rs.next()) {
        String coffeeName = rs.getString("COF_NAME");
        int supplierID = rs.getInt("SUP_ID");
        float price = rs.getFloat("PRICE");
        int sales = rs.getInt("SALES");
        int total = rs.getInt("TOTAL");
        System.out.println(coffeeName + "\t" + supplierID +
                           "\t" + price + "\t" + sales +
                           "\t" + total);
    }
}
0

con.setAutoCommit(true); the parameter to this method is true by default...why is it so ?? please help me know the reason for the default value true..

Edited by laavanya: spelling mistake

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.