import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.StringTokenizer; import java.sql.*; public class Partii extends HttpServlet { public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException { vastus.setContentType("text/html"); PrintWriter valja = vastus.getWriter(); String lpartiiid=""; valja.println("Partiid"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection( "jdbc:odbc:andmebaas", "", ""); Statement st=cn.createStatement(); String id=kysimus.getParameter("id"); String tegevus=kysimus.getParameter("tegevus"); if(id.equals("pealeht")) { String lause="SELECT * FROM partii"; ResultSet rs=st.executeQuery(lause); valja.println("
"); while(rs.next()) { valja.println(""); } valja.println("
Partii Nr
partii
"); valja.println("Link lisamise lehele"); } if(id.equals("lisamisleht")) { String viga=""; String midateha=kysimus.getParameter("midateha"); if(midateha.equals("lisa")) { String lax=kysimus.getParameter("lax"); String lay=kysimus.getParameter("lay"); String llx=kysimus.getParameter("llx"); String lly=kysimus.getParameter("lly"); String lloom=kysimus.getParameter("lloom"); String llopp=kysimus.getParameter("llopp"); if(lloom.equals("")) { viga="Viga lahtri täitmisel"; } else { if(llopp.equals("jah")) { String lause="INSERT INTO partii values ('');"; st.executeUpdate(lause); lause="SELECT * FROM partii where id=LAST_INSERT_ID()"; ResultSet rs=st.executeQuery(lause); while(rs.next()) { lpartiiid=rs.getString("id"); valja.println(lpartiiid); } String lause2="INSERT INTO kaik values ('', '"+lax+"', '"+lay+"', '"+llx+"', '"+lly+"', '"+lloom+"', '"+lpartiiid+"');"; st.executeUpdate(lause2); } if(llopp.equals("ei")) { String lause3="SELECT max(id) as id FROM partii"; ResultSet rs=st.executeQuery(lause3); while(rs.next()) { lpartiiid=rs.getString("id"); valja.println(lpartiiid); } String lause2="INSERT INTO kaik values ('', '"+lax+"', '"+lay+"', '"+llx+"', '"+lly+"', '"+lloom+"', '"+lpartiiid+"');"; st.executeUpdate(lause2); } } } valja.println("
"); valja.println(""); valja.println(""); valja.println("
AXAYLXLYLOOMLOPP
"+viga+"
"); } if(id.equals("info")) { String ax=""; String ay=""; String lx=""; String ly=""; String loom=""; String partii=kysimus.getParameter("partiiid"); valja.println("
"); String lause="SELECT * FROM kaik where partii_id='"+partii+"'"; ResultSet rs=st.executeQuery(lause); while(rs.next()) { ax=rs.getString("ax"); ay=rs.getString("ay"); lx=rs.getString("lx"); ly=rs.getString("ly"); loom=rs.getString("loom"); valja.println(""); } valja.println("
"+partii+". partii
"+loom+" astus "+ax+" : "+ay+" -lt "+lx+" : "+ly+" -le
"); } cn.close(); } catch(Exception viga) { viga.printStackTrace(valja); } //<--- valja.println(""); } }