import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.io.*; public class baasiparing extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ try{ vastus.setContentType("text/html"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn= DriverManager.getConnection( "jdbc:odbc:baasiyhendus1"); Statement st=cn.createStatement(); String lause="SELECT kogus FROM pallid"; ResultSet rs=st.executeQuery(lause); rs.next(); String tulemus="Laos on "+rs.getInt("kogus")+" palli."; PrintWriter valja=vastus.getWriter(); valja.println( "\n"+ tulemus+ "" ); }catch(Exception viga){ viga.printStackTrace(); } } }