import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.net.*; import java.sql.*; public class nimevaljastus2 extends HttpServlet{ public void doGet( HttpServletRequest kysimus, HttpServletResponse vastus ) throws IOException, ServletException{ PrintWriter valja=vastus.getWriter(); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:baasiyhendus1"); Statement st=cn.createStatement(); String lause="SELECT * FROM inimandmed"; if(kysimus.getParameter("sortvali")!=null && kysimus.getParameter("sortvali").equals("eesnimi")){ lause=lause+" ORDER BY eesnimi"; } ResultSet rs=st.executeQuery(lause); valja.println("Inimeste tabel"); valja.println(""); valja.println(""); valja.println(""); while(rs.next()){ valja.println(""); valja.println(""); valja.println(""); valja.println(""); } cn.close(); }catch(Exception viga){ viga.printStackTrace(valja); } valja.println("
EesnimiPerekonnanimihuvialad
"+rs.getString("eesnimi")+""+rs.getString("perenimi")+""+rs.getString("huvialad")+"
Valmis"); } } // select * from inimandmed order by perenimi