import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class Baasilooja3 extends HttpServlet{
  public void doGet(HttpServletRequest kysimus,
                    HttpServletResponse vastus)
          throws IOException, ServletException{
    vastus.setContentType("text/plain");
    PrintWriter valja=new PrintWriter(
                          vastus.getWriter());
   try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection cn=DriverManager.getConnection(
            "jdbc:odbc:yhendus", "", "");
    Statement st=cn.createStatement();
    String lause="SELECT * FROM bensiin;";
    ResultSet rs=st.executeQuery(lause);
//    valja.println("<html><head><title>bensujaamad</title></head><body>");
//    valja.println("<table><tr><td>MÜÜJA</td><td>HIND</td></tr>");
    while(rs.next()){
      valja.println(rs.getString("myyja")+" "+rs.getString("hind"));
    }
//    valja.println("</table></body></html>");
   }catch(Exception viga){
    valja.println("Probleem andmebaasiga: " +viga);
   }
  }
}