Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: help on servlet connection to oracle8i

Re: help on servlet connection to oracle8i

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Wed, 11 Aug 1999 16:28:27 -0700
Message-ID: <37B2071B.BCDC94EF@rationalconcepts.com>


Hi Stephen,
  To get a better idea of where java vm is going, put something like:    System.out.println(e.getMessage());
  and/or
   e.printStackTrace();
 in the exception handlers.
 This will give you a handle on what to start debugging.  Good luck!
Cindy

Stephen Wang wrote:

> 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:@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 - 18:28:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US