help on servlet connection to oracle8i

From: Stephen Wang <wangste_at_flux.cpmc.columbia.edu>
Date: Wed, 11 Aug 1999 17:42:27 -0400
Message-ID: <37B1EE43.6D04EA5F_at_flux.cpmc.columbia.edu>



[Quoted] Hi all,

    Recently I installed Oracle8i on my NT machine and tried to use servlet to connect to the starter database. The story was not successful. However, I could run the sample file (JdbcCheckup.java) that comes with Oracle8i which showed that the JDBC installation on Oracle8i was correct. The strange thing is that I have used the same connection code as that in the JdbcCheckup.java.

    Here I have provide some servlet codes. The program compiles but the connection could not be established. The program only outputs "before registration".

    Thanks so much for any suggestion.

    Stephen

import javax.servlet.*;
import javax.servlet.http.*;

import java.util.*;
import java.io.*;
import java.sql.*;
import java.net.URL;

public class TestOracle8i extends HttpServlet {

 public String getServletInfo()
 {
  return "A JDBC Servlet Example";
 }

 public void doGet(HttpServletRequest req, HttpServletResponse res)   throws ServletException, IOException
 {
  res.setContentType("text/html");
  PrintWriter out = res.getWriter();

  Connection con = null;

    try {

        out.println("before registration");

        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

        out.println("registration ok");

        con = DriverManager.getConnection("jdbc:oracle:oci8:_at_startdb", "scott", "tiger");

        out.println("Connection is good");
}

    catch (Exception e) {}

        // Any error is grounds for rollback     try {

        con.rollback();
}

    catch (Exception ignored) {

        //out.println("Order failed. Please contact technical support.");

}

    finally {

        // Clean up.
     try {
          if (con != null)
           con.close();
     }
     catch (SQLException ignored)
     { }

}

  }
} Received on Wed Aug 11 1999 - 23:42:27 CEST

Original text of this message