import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class PgTesti extends HttpServlet { // to use PostgeSQL: // final String dbDriver="org.postgresql.Driver"; // final String dbServer ="jdbc:postgresql://localhost:2023/template1"; // replace the above with your postgreSQL database id // to use Oracle 9 in bodbacka: final String dbDriver="oracle.jdbc.OracleDriver"; final String dbServer= "jdbc:oracle:thin:@bodbacka.cs.helsinki.fi:1521:test"; // nothing to replace // classpath must contain /opt/jdbc/oracle/classes12.zip final String dbUser= "scott"; // replace with your db user account final String dbPassword ="yiger"; // replace with your password public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletOutputStream out; res.setContentType("text/html"); out= res.getOutputStream(); out.println("
PgTesti"); out.println(""); } } catch (SQLException ee) { out.println("Tietokantavirhe "+ee.getMessage()); } finally { try { if (rs!=null) rs.close(); if (stmt!=null) stmt.close(); con.close(); } catch(SQLException e) { out.println("An SQL Exception was thrown."); } } out.println(""); out.println("