import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class Opilased extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=new PrintWriter(vastus.getWriter()); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn= DriverManager.getConnection("jdbc:odbc:inimesed", "", ""); Statement st=cn.createStatement(); String lause="SELECT eesnimi,perenimi FROM opilased;"; ResultSet rs=st.executeQuery(lause); valja.println( "<==Õpilaste andmebaas==>\n"+ "

Andmebaasis olevad õpilased

"); valja.println(""); valja.println(""); while(rs.next()){ valja.println(""); } valja.println("
Õpilase eesnimi
Õpilase perenimi
"); String eesnimi=rs.getString("eesnimi"); valja.println(eesnimi); valja.println(""); valja.println(rs.getString("perenimi")+("
")); valja.println("
"); }catch(Exception viga){ valja.println("Probleem andmebaasiga: " +viga); } } }