Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connencting to oracle

Status
Not open for further replies.

softjack

Programmer
Dec 4, 2005
44
IN
hi
i'm using two system (both winXP)
one system contains oracle 10G
other system contains tomcat-4.1.31 and java2 SDK 1.4.1
I just wan't to connect and access the oracle database (scott/tiger) either with jsp page or servlet.
I'm facing problem with oracle jdbc drivers...cannot compile!
maybe i'm doing something wrong as i'm new to tomcat.

just want some idea on where the drivers classes should be located. what changes to be made in the web.xml in WEB_INF...and whatever is needed.

I already downloaded the instantclient for oracle 10G.
There are some jar files and dll.

as for now i put these jar file in the CLASSPATH. Don't know what to do with the dll.
already set CATALINA_HOME, JAVA_HOME
also my javac is defined in the PATH variable.

Please i need some serious help here.

Thanks

Softjack
 
hi again

This the location of my jsp page
C:\jakarta-tomcat-4.1.3\webapps\examples\jsp\oracle\abc.jsp

this is my url to accesss this page

Here is my code example
Code:
<%@ page import="java.sql.*" %>

<HTML>
<HEAD><TITLE>Simple Oracle Example</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<B>Employees</B>
<BR><BR>

<%
   Connection conn = null;
   try
   {
  
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.getConnection(driver);


      conn = DriverManager.getConnection(
                "jdbc:oracle:thin:@192.168.0.2:1521:orcl",
                "scott",
                "tiger");

      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery("SELECT * FROM Emp");

      //Print start of table and column headers
      out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
      out.println("<TR><TH>ID</TH><TH>NAME</TH></TR>");

      //Loop through results of query.
      while(rs.next())
      {
         out.println("<TR>");
         out.println("<TD>" + rs.getString("empno") + "</TD>");
         out.println("<TD>" + rs.getString("eName") + "</TD>");
         out.println("</TR>");
      }

      out.println("</TABLE>");
   }
   catch(SQLException e)
   {
      out.println("SQLException: " + e.getMessage() + "<BR>");
      while((e = e.getNextException()) != null)
         out.println(e.getMessage() + "<BR>");
   }
   
   finally
   {
      //Clean up resources, close the connection.
      if(conn != null)
      {
         try
         {
            conn.close();
         }
         catch (Exception ignored) {}
      }
   }
%>

</CENTER>
</BODY>
</HTML>

code

this is the error i get
Code:
         Employees 
SQLException: No suitable driver


Hope this will help in solving my problem.

Softjack
 
There should be a jar file called classes12.jar in ORACLE_HOME/lib. This is all you need to connect to Oracle via JDBC - you don't need any dll's or anything.

You should put this file in TOMCAT_HOME/common/lib or TOMCAT_HOME/shared/lib.

If you want to connect to Oracle via JDBC standalone connections (ie not via connection pooling), then you do not need to make any changes in server.xml or web.xml.

You do not need the Oracle instant client either - just the classes12.jar file as mentioned earlier.

Without actual error messages, I cannot offer any more advice.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top