aquemini001
asked on
What would the code to do this database?
This is the database:
COF_NAME SUP_ID PRICE SALES TOTAL
-------- ------ ----- ----- -----
Colombian 101 7.99 75 0
French_Roast 49 8.99 10 0
Espresso 150 9.99 60 0
What is the output of this code if i run it against this database.
String query = "SELECT COF_NAME, SALES FROM COFFEES " +
"WHERE SALES >=40";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String s = rs.getString("COF_NAME");
int n = rs.getInt("SALES");
System.out.println(n + " pounds of " + s + " sold this week.");
COF_NAME SUP_ID PRICE SALES TOTAL
-------- ------ ----- ----- -----
Colombian 101 7.99 75 0
French_Roast 49 8.99 10 0
Espresso 150 9.99 60 0
What is the output of this code if i run it against this database.
String query = "SELECT COF_NAME, SALES FROM COFFEES " +
"WHERE SALES >=40";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String s = rs.getString("COF_NAME");
int n = rs.getInt("SALES");
System.out.println(n + " pounds of " + s + " sold this week.");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
you;re right. sorry. thanks for the help.
thanks :-)
Your output as per the System.out.println () would be:
75 pounds of Colombian sold this week.
60 pounds of Espresso sold this week.
BTW, you can check the output yourself. What more do you want to ask? If you only want the output of the query explained as per what maheshexp has done, it is more of a database question than a Java question~!
JDBC tutorial - http://java.sun.com/docs/books/tutorial/jdbc/