• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

once again: classpath and ojdbc14.jar

 
Dirk Huth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy folks,

I'm sure my question has been asked several times before, but I can't seem to find a fitting thread with the solution in this forum. Hope any of you has the patience to guide me through this.

I am "educating myself on technology", as it says on the respective IBM sites, so I downloaded a WebSphere Application Server v7 (base trial) and am experimenting with this now. I deployed a simple application which makes a connection to an Oracle Express DB (10g Express Edition Release 10.2.0.1.0) - that works, so I must have gotten something right. (Both the App-Server and the DB are running on localhost. For previous experiments I have changed Oracle's listener port to 1621 - in case anyone wonders.)

Now I am trying to test the oracle-connection with a stand-alone java-program I found on the net and I can't get the thing to acknowledge the driver: Where does this ojdbc14.jar go ???

Here's the program:



Thats my classpath:


And here is all the places where I dropped the driver:


The prog compiles alright, but when executed stops at line 15, even when I add the current directory to the classpath-option via


I keep getting "Exception: oracle.jdbc.OracleDriver" from the prog. I'm sure this is just some minor fault but I am absolutely stuck. Any help much appreciated, thanks in advance

Dirk

 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"home/dirk/myscripts/java/oracle_tests/ojdbc14.jar"


That path is a relative path, which means it's relative to your current working directory. So if your current working directory was (say) "/users/dirk", that path would represent

"/users/dirk/home/dirk/myscripts/java/oracle_tests/ojdbc14.jar"


But that wasn't what you said you meant. You said you meant

"/home/dirk/myscripts/java/oracle_tests/ojdbc14.jar"


So use that absolute path instead of the relative path which isn't right.
 
Dirk Huth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

first of all - thanks for the quick reply! Unfortunately that didn't help. I'm on Ubuntu, so there is no directory /users/... There's just /home/... and e.g. /home/dirk

Anyway, it doesn't work.

Neither

javac -cp "/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/ojdbc14.jar" OracleConnectionUrl.java

nor

javac -cp "/home/dirk/myscripts/java/oracle_tests/ojdbc.jar

Both get the same "Exception: oracle.jdbc.OracleDriver". So now I wonder is this the correct driver for Oracle Express DB (10g Express Edition Release 10.2.0.1.0)? (I guess it must be, because that's the driver I installed into the app-server and there it works.) Or am I using the "wrong" jdk? I have openjdk-6-jdk?

Hope we can finagle this out, best greetings,

Dirk
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well for one thing, classpath aside, your code as shown will not get a Connection except on the first shot. If the first try throws an Exception all the other attempts to get the Connection will not be tried.
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you're using specific objects from the Oracle driver, you don't need to include the Oracle driver to compile your code. Also, have you tried Class.forName("oracle.jdbc.driver.OracleDriver"); instead?
 
Dirk Huth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bill: Yeah, but it's just a simple test. Since it is so basic it is supposed to work for all attempts without catching an exception.

@Koen: Yes I have - just now. The only thing that changes is the error-message:
Exception: oracle.jdbc.driver.OracleDriver

Also: compiling without explicitly invoking the path to the driver produces the same error.

I'm sure it's just a simple oversight somewhere but I can't get at it.

 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Provide a copy of the EXACT javac and java commands you're running, the paths from which you're running it, the resulting stacktrace/error message and the source of the java file you're trying to compile/run.
 
Dirk Huth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Koen,

I'm afraid I don't quite see where you're getting at: The complete code is in my first post, as well as the javac-command I used. Below a copy of the things I'm trying, this time with the directory paths:


dirk@dirk-portable:~/myscripts/java/oracle_tests$ ls
HelloWorldApp.class HelloWorldApp.java ojdbc14.jar OracleConnectionUrl.class OracleConnectionUrl.java
dirk@dirk-portable:~/myscripts/java/oracle_tests$ javac -cp "/home/dirk/myscripts/java/oracle_tests/ojdbc14.jar" OracleConnectionUrl.java
dirk@dirk-portable:~/myscripts/java/oracle_tests$ java OracleConnectionUrl
Exception: oracle.jdbc.driver.OracleDriver
dirk@dirk-portable:~/myscripts/java/oracle_tests$


The Oracle-DB is running, I'm on a Linux VM (Ubuntu, lucid), I use openjdk 6, I changed the driver-definition both in the import statement and in the Class.forName statement according to your suggestion to oracle.jdbc.driver.OracleDriver.

Have you any suggestions as to what kind of trace I could try?

Thanks,

Dirk
 
Dirk Huth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

it works now - although I'm not sure why. (As I said: absolute newbie.)

First I included the directory once more in the cp-argument:


(I saw that when working with a mySQL-example. I don't understand why this is necessary, though.)

got an error with the driver import so I commented it out

when I finally got to the "driver loaded ok" message I finagled it out with the help of google that the connection-string must include "user" and "password" as well, like


Best greetings,
Dirk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic