1

I'm confused because java is not working with Oracle. I'm trying to connect java to Oracle but I'm getting oracle.jdbc.driver.OracleDriver exception. I follow the all steps. Placed the ojdbc.jar file in jre/lib/ext director but still getting same exception. Recently It was working fine. But recently I installed windows and Oracle again. But during installation of Oracle by mistake I change the path in installation and now my Oracle directories are in this order.

admin
audit
cfgtoollogs
checkpoints
diag
OracleHome
--oradata
--product

But before new installation when connection working fine the Directory order was in this order.

OracleHome
--admin
--audit
--cfgtoollogs
--checkpoints
--diag
--oradata
--product

I'm confused may be exception could be caused due to this directories hirarchy? if yes then how I can solve it?

  • Directories have nothing to do with it. You point your java app to an address which the oracle is at, not to a directory. Your problem is related to dependencies not being in the classpath, afterall it doesn't make sense where you put driver jar. – dambros Apr 15 '16 at 08:38
  • @dambros I put driver jar in `C:\Program Files\Java\jre1.8.0_60\lib\ext` –  Apr 15 '16 at 08:39
  • @dambros, here is question http://stackoverflow.com/questions/36641369 regarding on same problem. by Let Do it. whatever dambros said is correct, it has nothing do with oracle installation. its'about the your java program. – Viraj Apr 15 '16 at 08:43
  • I usually prefer adding it to classpath. In any case, almost sure you are putting it in the wrong place. Check where your JAVA_HOME variable points to (probably jdk folder) and inside there should be a jre folder – dambros Apr 15 '16 at 08:43

1 Answers1

0

The installation path is not important for the database connection from Java, the only important things are hostname/ip address of the server, server port, username, password and database alias. You have to check that all these informations are not changed with the new installation. Try to connect to your oracle database with a database client, if the connection works correctly then try to connect from your Java application. Here you can read a simple example:

http://www.mkyong.com/jdbc/connect-to-oracle-db-via-jdbc-driver-java/

I hope it can be useful for you.

TeoVr81
  • 989
  • 15
  • 33