Can't find Oracle JDBC Driver

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Can't find Oracle JDBC Driver

 
0
  #1
Feb 6th, 2008
I am trying to work on a project for school from home. The school computer has Oracle and I am trying to access it from home using Java/JSP. Currently I have Java SE with NetBeans installed on my home machine (Windows XP SP II), but not Tomcat or Oracle. The database that I am accessing is stored completely on the Oracle machine at school. One question I have is, given that, must I install Oracle at home too in order to get these JDBC drivers or do the drivers come with Java?

Researching the web, the solutions have involved setting up path and classpath with directories including ORACLE_HOME, which I believe does not exist on my computer since I have not installed Oracle. Here is the code I have written:

  1. // Filename : DeptTableInteraction.java
  2.  
  3. package DBinteraction;
  4.  
  5. import java.sql.* ;
  6. import java.awt.*;
  7. import java.awt.event.*;
  8. import java.io.*;
  9. import java.util.*;
  10. import java.lang.*;
  11.  
  12. public class DeptTableInteraction
  13. {
  14. public DeptTableInteraction ()
  15. {
  16. System.out.println ("So Far So Good 1\n");
  17. try
  18. {
  19. System.out.println ("So Far So Good 2\n");
  20. Class.forName("oracle.jdbc.driver.OracleDriver");
  21. System.out.println ("So Far So Good 3\n");
  22. }
  23. catch (ClassNotFoundException ex)
  24. {
  25. System.out.println ("Something Bad Happened\n");
  26. }
  27. }
  28. public static void main(String[] args) throws SQLException
  29. {
  30. DeptTableInteraction dti = new DeptTableInteraction();
  31. }
  32. }

It compiles. The results are the following after compiling/running through NetBeans:


init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Bob\NetbeansProjects\Java\DeptTableInteraction\build\classes
compile:
So Far So Good 1

So Far So Good 2

Something Bad Happened

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
debug:
BUILD SUCCESSFUL (total time: 1 second)

So the questions are:
1) Do I need to install Oracle on my local machine even though the database is stored elsewhere?
2) Where does this driver come from (Oracle or Sun)?

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,448
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 261
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Can't find Oracle JDBC Driver

 
0
  #2
Feb 7th, 2008
Do you have the oci or the thin Oracle Driver. If you have the oci driver, then yes, I believe you do need to have an Oracle client install on your machine (at least you don't need a complete Oracle install, just a couple of libraries and a few config files). If you have the thin driver, then you don't need that (it has less functions, fromwhat I've heard, than the oci Driver, but I've never missed them). If you have the oci Driver, then I would say to dowload and use the thin Driver.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Can't find Oracle JDBC Driver

 
0
  #3
Feb 7th, 2008
Thanks for the response. I believe that the driver that I need is the "thin" driver. Some code from someone else that I am sort of using as a skeleton is this:

  1. Connection conn = DriverManager.getConnection(
  2. "jdbc:oracle:thin:@"school-server-address":1521:orcl",
  3. "oracle-user-id", "oracle-password");

Like I said, Oracle is not currently installed. However, I do have a file called "ojdbc14.jar", which came from an earlier Oracle installation. I have heard that this may be the right file for these drivers? So this driver, since it can came with an Oracle install, was written by Oracle rather than Sun? Basically I haven't tried to use this jar file because one, I don't know whether I'm supposed to use it or if there is some driver that was installed when I installed Java that I am supposed to use instead, and two, if I am supposed to use it and it contains what I need, where do I put it and how do I access it?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,448
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 261
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Can't find Oracle JDBC Driver

 
0
  #4
Feb 7th, 2008
That is the thin driver, and yes you need to use it.

Place it anywhere you want to place it, and refer to it on the CLASSPATH.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Can't find Oracle JDBC Driver

 
0
  #5
Feb 7th, 2008
O.K., I put the jar file on my Desktop for now and changed the "Properties" section of my project in NetBeans so that the "compile" tab adds that jar file. I'm still learning how to set the classpath so I'm not sure whether I actually did that or not (sometimes NetBeans figures out a lot for you). I'm going to experiment around. Regardless, doing that appears to have worked. I ran a slightly longer test program than what I posted and was able to create a new database table on the remote computer's Oracle database from my home machine hundreds of miles away. All of my "try" code worked and nothing was "caught" so hopefully it's all good. That was a small example and hopefully things will work as the project gets more elaborate. But for now it's working!

Thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,448
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 261
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Can't find Oracle JDBC Driver

 
0
  #6
Feb 7th, 2008
Adding to the "build" path on Netbeans is adding to the classpath (at least within Netbeans).
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Can't find Oracle JDBC Driver

 
0
  #7
Feb 7th, 2008
And mind that the thin driver consists of 2 jar files for recent versions (1 for really old versions), the names of which depend on the version of Oracle being used.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC