import java.text.*; import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class vaatamuuzik extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ PrintWriter valja=new PrintWriter(vastus.getWriter()); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn= DriverManager.getConnection("jdbc:odbc:andmed", "", ""); Statement st=cn.createStatement(); String idnr=kysimus.getParameter("id"); String haaled=kysimus.getParameter("haaled"); int punktid=0; // if (haaled.equals("1") || haaled.equals("2") || haaled.equals("3") || haaled.equals("4") || haaled.equals("5")){ String lause="UPDATE muuzik SET punktid=punktid+"+haaled+" WHERE id="+idnr+";"; st.executeUpdate(lause); lause="UPDATE muuzik SET haaled=haaled+1 WHERE id="+idnr+";"; st.executeUpdate(lause); lause="UPDATE muuzik SET keskmine=punktid/haaled WHERE id="+idnr+";"; st.executeUpdate(lause); // }else{ // } // String lause="SELECT id, esitaja, lugu, punktid, haaled, keskmine FROM muuzik ORDER BY keskmine DESC;"; ResultSet rs=st.executeQuery(lause); int nr=0; valja.println("
Bänd | "+ "Lugu | "+ "|||
"+m_esitaja[arv]+" | "+ ""+m_lugu[arv]+" | "+ "|||
"+m_esitaja[nr]+" | "+ ""+m_lugu[nr]+" | "+ "