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