 import java.sql.*;

    

public class selectKahve {

                public static void main(String args[]) {                             

                String url = "jdbc:odbc:prog";

                                Connection con;

                                Statement stmt;

                String query = "select KAHVE_ISMI, FIYAT from KAHVE";

                                try {

                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

                    } catch(java.lang.ClassNotFoundException e)

                      {

                      System.err.print("ClassNotFoundException: ");

                      System.err.println(e.getMessage());

                      }

                                try {

                      con = DriverManager.getConnection(url,

                      "myLogin", "myPassword");

                      stmt = con.createStatement();

                                                ResultSet rs = stmt.executeQuery(query);      

                                                System.out.println("Coffee Break Coffees and Prices:");

                                                while (rs.next()) {

                                          String s = rs.getString("KAHVE_ISMI");

                                          float f = rs.getFloat("FIYAT");

                                                System.out.println(s + "   " + f);

                                                }             

                                                stmt.close();

                                                con.close();          

                                } catch(SQLException ex) {

                                                System.err.println("SQLException: " + ex.getMessage());

                                }

                }

}

