import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class Laenutatud extends HttpServlet{
public void doGet(HttpServletRequest kysimus,
HttpServletResponse vastus)
throws IOException, ServletException{
vastus.setContentType("text/html");
PrintWriter valja=new PrintWriter(
vastus.getWriter());
try{
String kood=kysimus.getParameter("kood");
if(kood==null){
valja.println("
LAENUTUSTE OSAKOND");
valja.println("");
}else{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection(
"jdbc:odbc:yhendus2", "", "");
Statement st=cn.createStatement();
String lause="SELECT * FROM video where laen_id="+kood;
// valja.println(lause);
ResultSet rs=st.executeQuery(lause);
while(rs.next()){
valja.println("FILMID SINU KÄES: "+rs.getString("pealkiri")+", zanr: "+rs.getString("zanr")+ ", ja tagastamise tähtaeg on "+rs.getString("kuupaev")+"
");
}
}
valja.println("Tagasi avalehele");
}catch(Exception viga){
valja.println("Probleem andmebaasiga: " +viga);
}
}
}