import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class lisamine extends HttpServlet{ public void doPost(HttpServletRequest paring, HttpServletResponse vastus) throws IOException, ServletException{ doGet(paring, vastus); } public void doGet(HttpServletRequest paring, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=new PrintWriter(vastus.getWriter()); String sisse1 =paring.getParameter("t1"); String sisse2 =paring.getParameter("t2"); String sisse3 =paring.getParameter("t3"); String sisse4 =paring.getParameter("t4"); String sisse5 =paring.getParameter("t5"); try{ if (sisse1 !=null && sisse2 !=null && sisse3 !=null && sisse4 !=null && sisse5 !=null){ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:java", "", ""); Statement st=cn.createStatement(); String sql="INSERT INTO klient (Perenimi,Eesnimi,Tanav,Maja,Korter)"+ "values ('"+sisse1+"','"+sisse2+"','"+sisse3+"','"+sisse4+"','"+sisse5+"');"; st.executeUpdate(sql); cn.close(); } }catch(Exception e){e.printStackTrace(valja);} valja.println("\n"); valja.println("
\n"); valja.println("

Andembaasi lisamine

\n" ); valja.println("\n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ "
Perekonnanimi \n"+ " \n"+ "
Eesnimi\n" + " \n"+ "
Tänav\n" + " \n"+ "
Maja\n" + " \n"+ "
Korter\n" + " \n"+ "
 \n"+ " \n"+ "
\n
" ); valja.println("\n"); } }