// Java Document import java.io.*; import java.sql.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class VapraHindamine extends HttpServlet { public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException { try{ ResourceBundle rb = ResourceBundle.getBundle("LocalStrings",kysimus.getLocale()); vastus.setContentType("text/html"); PrintWriter out = vastus.getWriter(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:Baas1"); Statement st=cn.createStatement(); out.println(""); out.println(""); out.println(" Hindamine "); out.println(""); out.println(""); out.println(""); int laulu_id = Integer.parseInt(kysimus.getParameter("id")); int hinne = Integer.parseInt(kysimus.getParameter("hinne")); out.println("

Hindasid seda laulu " + hinne + "-ga!
"); out.println("Täname hindamast!
"); out.println("<< Tagasi edetabeli lehele

"); out.println(""); out.println(""); String paring = "INSERT INTO vaprate_hinded (laulu_id, hinne) VALUES ('" + laulu_id + "', '" + hinne + "');"; st.executeUpdate(paring); String paring2 = "UPDATE vaprad SET hinnatud=1 WHERE id=" +laulu_id+ ";"; st.executeUpdate(paring2); cn.close(); }catch (Exception viga){viga.printStackTrace();} } }