• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • 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("jbdcracle: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 Exceptionracle.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 ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Any Help Guys?/

Thanks.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • 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.
 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
JIA Jerry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Jan Cumps
Bartender
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic