import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.lang.Object.*;
import java.sql.*;

public class AndmedSisse extends HttpServlet{
	Connection cn;
	
	public AndmedSisse(){
		try{
			
		}catch(Exception e){
			System.out.println("v1:"+e);
		}		
	}	
	//*****************************************//
	public void doGet(HttpServletRequest k, HttpServletResponse vastus) throws IOException, ServletException{	
		PrintWriter pw=vastus.getWriter();
		try{			
			
			vastus.setContentType("text/plain");			
			String lause;
			ResultSet rs;
			Statement st;
			
					String nimi=k.getParameter("nimi");
					String punkte=k.getParameter("punkte");
					
					Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");			
					cn=DriverManager.getConnection("jdbc:odbc:andmed", "", "");			
					st=cn.createStatement();
					
					lause="INSERT INTO skoorid (nimed, punktid) VALUES ('"+nimi+"',"+Integer.parseInt(punkte)+")";
					st.executeUpdate(lause);					
					
					
					lause="select count(*) as nr from skoorid where punktid>="+Integer.parseInt(punkte)+";";
					st=cn.createStatement();
					rs=st.executeQuery(lause);
					rs.next();
					pw.println(rs.getString("nr"));					
					
					cn.close();
			
			
		}catch(Exception e){
			//pw.println("");
		}
	}
}