facebook

Not able to connect to Oracle

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #244692 Reply

    Hey,

    I am currently unable to connect to oracle. I just switched from sunserver to apache and have just started using myeclipse. I added ojdbc14.jar to my build path and the connection code is shown below. I was able to connect before with sunserver and a different IDE (although that shouldn’t matter). I don’t remember importing any other packages. I have also tried it with classes12.zip..no difference…I get the same basic error. help please.

    java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

    public void getConnection()
    {
    try
    {
    Class.forName(“oracle.jdbc.driver.OracleDriver”);

    }

    catch(Exception e)
    {
    System.out.println(“PROBLEM WITH DRIVER”);
    e.printStackTrace();
    }

    try
    {

    con = DriverManager.getConnection(“jdbc:oracle:thin:xxx/yyy@zzz:aaa:bbb”);

    con.setAutoCommit(false);

    }

    catch(Exception e)
    {
    System.out.println(“PROBLEM WITH CONNECTION”);
    e.printStackTrace();
    }

    }

    #244699 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    You are getting a ClassNotFoundException so chances are you aren’t adding the oracle driver correctly to your build path, or you added it, then moved the JAR. Either way that seems to be the problem.

    #244701 Reply

    I haven’t moved it. I have both ojdbc14.zip and classes12.zip in my build path. The odd thing is myeclipse obviously recognizes the packages or it wouldn’t even let me build in the first place as I’m declaring oracleresultsets and BLOB’s everywhere. Yet it fails to find
    oracle.jdbc.driver.OracleDriver. I’m just adding both ojdbc14.zip and classes12.zip as archives to my project.

    #244702 Reply

    Riyad Kalla
    Member

    Is this client code or web code? If it’s web code you need to place your drivers into your app server’s lib directory so the app server can pickup the classes. For tomcat that is common/lib

    #244704 Reply

    Okay added both classes12.zip and ojdbc14.zip to common. Still get the same error. I’m completely baffled.

    #244705 Reply

    I meant added to common/lib

    #244706 Reply

    Riyad Kalla
    Member

    As a last ditch effort try and add them to WEB-INF/lib and deploy. I have no idea why this isn’t working.

    You sure you are launching the install of Tomcat you think you are? (I’ve done that, had two installs and been modifying the config of a separate install and keep relaunching the old one and going crazy)

    #244707 Reply

    Is there any other information that might be of use to help solve this problem. Is there any other zips I need perhaps. I’ve restarted and shutdown my server a number of times to no avail.

    #244709 Reply

    Riyad Kalla
    Member

    Pichai,
    This is a straight forward issue; ClassNotFoundException. The fact that it is taking this long to figure out with only 2 possible solutions makes me thing the problem is something even sillier than we might think it is.

    For example, you have setup your Tomcat connector to launch the wrong Tomcat instance.

    You are launching JBoss but keep making changes to Tomcat.

    stuff like that.

    I would say go back to basics. Go download Tomcat 5.5.9 ZIP, unzip it to a new dir, go configure your Tomcat 5 connector to point at it (e.g. C:\temp\tomcat-5) then run it. Make sure it starts up alright. Now stop it.

    Now go drop the oracle drivers into common/lib dir of the new tomcat install, now deploy your app to it and start it back up, now try and connect.

    #244712 Reply

    I found out what was happening…it still makes no sense to me but it works now…just put ojdbc14 jar into the common\lib instead of ojdbc zip. Very silly error. I just didn’t know that tomcat

    #244713 Reply

    just didn’t know that tomcat didn’t recognize zip files

    #244714 Reply

    Riyad Kalla
    Member

    Odd. Glad it’s working now.

Viewing 12 posts - 1 through 12 (of 12 total)
Reply To: Not able to connect to Oracle

You must be logged in to post in the forum log in