import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class Laulud2 extends HttpServlet { public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException { vastus.setContentType("text/plain"); PrintWriter valja = vastus.getWriter(); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection( "jdbc:odbc:esimene", "", ""); Statement st=cn.createStatement(); String lause="SELECT pealkiri, esitaja FROM laulud"; ResultSet rs=st.executeQuery(lause); while(rs.next()){ valja.println(rs.getString("pealkiri")+ " "+rs.getString("esitaja")+"\n"); } cn.close(); }catch(Exception viga){ viga.printStackTrace(valja); } } }