import java.sql.*;


public class KAHVE
{
  public static void main(String[] args) throws ClassNotFoundException
  {
    //  sqlite-JDBC sürücüsünü yükle 
    Class.forName("org.sqlite.JDBC");   
    Connection connection = null;
    try
    {
      // veritabanı ile bağlantı kur.
      connection = DriverManager.getConnection("jdbc:sqlite:temp.db");
      Statement statement = connection.createStatement();     
      statement.setQueryTimeout(30);  // set timeout to 30 sec.
      statement.executeUpdate("drop table if exists KAHVE");
      statement.executeUpdate("create table KAHVE(isim String, kot int, fiyat double, miktar int,toplam double)");
      statement.executeUpdate("insert into KAHVE values('Espresso',150,9.99,110,0);");
      statement.executeUpdate("insert into KAHVE values('Venezuella',173,12.99,57,0);");
      statement.executeUpdate("insert into KAHVE values('Brezilya',123,12.99,30,0);");
      statement.executeUpdate("insert into KAHVE values('Kolombia',111,15.99,20,0);");
      statement.executeUpdate("update KAHVE set toplam=fiyat*miktar;");    
      ResultSet rs = statement.executeQuery("select * from KAHVE");
      while(rs.next())
      {
        // read the result set
        System.out.print("KAHVE İSMİ = " + rs.getString("isim"));
        System.out.print(" KOT = " + rs.getInt("kot"));
        System.out.print(" FİYAT = " + rs.getDouble("fiyat"));
        System.out.print(" MİKTAR = " + rs.getInt("miktar"));
        System.out.println(" TOPLAM = " + rs.getDouble("toplam"));
      }
    }
    catch(SQLException e)
    {
      // if the error message is "out of memory", 
      // it probably means no database file is found
      System.err.println(e.getMessage());
    }
    finally
    {
      try
      {
        if(connection != null)
          connection.close();
      }
      catch(SQLException e)
      {
        // connection close failed.
        System.err.println(e);
      }
    }
  }
}
