import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class Baasilooja4 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("
Laenutuse vaatamine");
valja.println("");
}else{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection(
"jdbc:odbc:yhendus1", "", "");
Statement st=cn.createStatement();
String lause="SELECT * FROM raamatud where in_id="+kood;
// valja.println(lause);
ResultSet rs=st.executeQuery(lause);
while(rs.next()){
valja.println("Sul on praegu käes "+rs.getString("pealkiri")+", autor: "+rs.getString("autor")+ ", ja tagastamise tähtaeg on "+rs.getString("laenu_loppaeg")+"
");
}
}
valja.println("Tagasi avalehele");
}catch(Exception viga){
valja.println("Probleem andmebaasiga: " +viga);
}
}
}