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...

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 2 Years Ago by stultuske

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);
    }
}

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 2 Years Ago by laavanya: spelling mistake

This article has been dead for over six months. Start a new discussion instead.