import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class MituTabelit9 extends HttpServlet { public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException { PrintWriter valja = vastus.getWriter(); vastus.setContentType("text/html"); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:AndmeBaas", "", ""); Statement st=cn.createStatement(); Statement st2=cn.createStatement(); Statement st3=cn.createStatement(); Statement st22=cn.createStatement(); Statement st55=cn.createStatement(); Statement st5=cn.createStatement(); //###################################################################################### if(kysimus.getParameter("otsimine")!=null){ String eesnimi2=kysimus.getParameter("eesnimi"); String perenimi2=kysimus.getParameter("perenimi"); String idee2= "SELECT synd FROM inimesed WHERE inimesed.eesnimi='"+eesnimi2+"'and inimesed.perenimi='"+perenimi2+"'"; ResultSet rs2= st2.executeQuery(idee2); if(rs2.next()){ String mid2=rs2.getString("synd"); String idee22= "SELECT paev, kuu, aasta FROM synniaeg WHERE synniaeg.id='"+mid2+"'"; ResultSet rs22= st22.executeQuery(idee22); //***************************************************************************** valja.println("Sünniaeg"); while(rs22.next()){ valja.println(rs22.getString("paev")+"."+rs22.getString("kuu")+"."+rs22.getString("aasta")); valja.println(); } //***************************************************************************** //valja.println(mid2+"\n"); }else{ valja.println("Sellist nime andmebaasis ei ole"); } //######################################################################################## String idee5= "SELECT elupaik FROM inimesed WHERE inimesed.eesnimi='"+eesnimi2+"'and inimesed.perenimi='"+perenimi2+"'"; ResultSet rs5= st5.executeQuery(idee5); if(rs5.next()){ String mid5=rs5.getString("elupaik"); String idee55= "SELECT maakond, linn, tanav, maja, korter FROM elukoht WHERE elukoht.id='"+mid5+"'"; ResultSet rs55= st55.executeQuery(idee55); //***************************************************************************** valja.println("Elukoht"); while(rs55.next()){ valja.println(rs55.getString("maakond")); valja.println(rs55.getString("linn")); valja.println(rs55.getString("tanav")); valja.println(rs55.getString("maja")); valja.println(rs55.getString("korter")); } //***************************************************************************** //valja.println(mid2+"\n"); }else{ valja.println("Sellist nime andmebaasis ei ole"); } //*************************************************************************************************** } //*************************************************************************************************** cn.close(); }catch(Exception viga){ viga.printStackTrace(valja);} } }