import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class Baasilooja5 extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/plain"); PrintWriter valja=new PrintWriter( vastus.getWriter()); try{ String kood=kysimus.getParameter("kood"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection( "jdbc:odbc:yhendus1", "", ""); Statement st=cn.createStatement(); String lause="SELECT * FROM raamatud"; ResultSet rs=st.executeQuery(lause); while(rs.next()){ valja.println("Pealkiri: "+rs.getString("pealkiri")+", autor: "+rs.getString("autor")); } }catch(Exception viga){ valja.println("Probleem andmebaasiga: " +viga); } } }