• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Installed Oracle 10g in my Local system and now I am having problem connecting to it

 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I Installed Oracle 10g in my Local system and now I am having problem connecting to it from my java code. Below is my Code.


try {
Class.forName("oracle.jdbc.driver.OracleDriver"); // Loads the Driver
Connection connect = DriverManager.getConnection("jbdc:oracle:thin:@//localhost:1521/XE","System","1234"); // Establishing Connection
Statement stmnt = connect.createStatement(); // To create a Statement
ResultSet rs = stmnt.executeQuery("insert into a values ( 1 )"); // Execute a query
}


catch(java.lang.ClassNotFoundException e1)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e1.getMessage());
}

catch(java.sql.SQLException e2)
{
System.err.print("Sql exception ");
System.err.println(e2.getMessage());
}

System and 1234 are the User name and Password for my local machine database.I have already created a table named a and I am trying to insert a value into it's attribute. I am however getting this exception"Class not found Exception:oracle.jdbc.driver.OracleDriver" Should I specifically look into anything?/ Oracle in my machine is running on port 8081 and I have already included the following import statements:

import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.Enumeration;


Thanks.

[ March 05, 2008: Message edited by: Arjun Reddy ]

[ March 05, 2008: Message edited by: Arjun Reddy ]
[ March 05, 2008: Message edited by: Arjun Reddy ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Oracle driver need to be on your application's classpath.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

I have added the oracle driver(The Jar file) to My System's class path and I have opened a new window and tried to run the program but it's still giving the same error. I have also checked the Service name(XE) and the Port Number(1521) from the TnsNames.Ora file.


Thanks.
[ March 05, 2008: Message edited by: Arjun Reddy ]
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any Help Guys?/

Thanks.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've found the problem. I have added the oracle driver to the class path but forgot to include the .jar along with the file name. Thanks for looking in guys.

Thanks.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can you tell me the .jar file name that you use for your code and do you use it in javac or java?

Thanks
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry I just saw ya reply. I put the following jar file in my class path:
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14_g.jar

It's supposed to be called as the Oracle driver.

Thanks.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I HAVE A SAME PROBLEM............

I have the following information in my classpath.

C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14_g.jar;C:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar;C:\oracle\product\10.2.0\db_1\jdbc\lib;C:\Program Files\Java\jdk1.5.0_17\bin;C:\Download;C:\;C:\Program Files\Java\jre6\lib\ext\QTJava.zip


Following Location where I have classes classes12.jar and classes12.zip files exists.

C:\oracle\product\10.2.0\db_1\jdbc\lib

What else I have to put it in Classpath?

JAVA VERSION
java version "1.6.0_13"

IF I RUN THE FOLLOWING COMMAND
jar tvf C:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar oracle\jdbc\driver\OracleDriver.class

I get the following line
13666 Wed Jun 22 11:16:02 MDT 2005 oracle/jdbc/driver/OracleDriver.class

Regards
Jerry
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, you woke up an old post. Better create a new post next time.

Please first start with cleaning up your classpath.

C:\Program Files\Java\jdk1.5.0_17\bin is no location to have on your classpath. Because it does not contain any java classes, and you are using java version "1.6.0_13" . Why did you add it to your classpath?

Then, check out the appropriate Oracle drivers for java version "1.6.0_13", and use them *only*. Check out Oracle web for more info.

currently you mixed these two:
C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14_g.jar
C:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar

Then, please post the exact error message you get, rather than "I HAVE A SAME PROBLEM............ "




 
JIA Jerry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
I fixed the problem by replacing the jdbc file.

C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar

Thanks
reply
    Bookmark Topic Watch Topic
  • New Topic