import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class baas extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=vastus.getWriter(); String a=kysimus.getParameter("submit"); try{ //// /*if(a!=null){ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn2=DriverManager.getConnection("jdbc:odbc:poebaas", "", ""); Statement st2=cn2.createStatement(); ResultSet rs2=st2.executeQuery("INSERT into isik (eesnimi, perenimi, isikukood, kursus) values("+kysimus.getParameter("eesnimi")+","+kysimus.getParameter("perenimi")+","+kysimus.getParameter("isikukood")+""+kysimus.getParameter("kursus")+"); cn2.close(); }*/ //// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:poebaas", "", ""); Statement st=cn.createStatement(); ResultSet rs=st.executeQuery("SELECT * FROM isik"); valja.println(""); valja.println(""); while(rs.next()){ valja.println(""); } valja.println("
EesnimiPerekonnanimikursusIsikukood
"+rs.getString("eesnimi")+""+rs.getString("perenimi")+""+rs.getString("kursus")+""+rs.getString("isikukood")+"
"); cn.close(); valja.println("

Otsing

kursus


"+ "Eesnimi


"+ "Perenimi


"+ "
"); String b=kysimus.getParameter("submit"); if(b!=null){ valja.println(""); ResultSet rs2=st1.executeQuery("SELECT * FROM isik WHERE kursus='"+kursus+"' OR perenimi='"+perenimi+"' OR eesnimi='"+eesnimi+"'"); valja.println(""); while(rs2.next()){ valja.println(""); } valja.println("
EesnimiPerekonnanimikursusIsikukood
"+rs2.getString("eesnimi")+""+rs2.getString("perenimi")+""+rs2.getString("kursus")+""+rs2.getString("isikukood")+"
"); cn.close(); } } catch(Exception e){ e.printStackTrace(valja); } } }