GeeCON Prague 2014*
The moose likes JDBC and the fly likes Installed Oracle 10g in my Local system and now I am having problem connecting to it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Installed Oracle 10g in my Local system and now I am having problem connecting to it" Watch "Installed Oracle 10g in my Local system and now I am having problem connecting to it" New topic
Author

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

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
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 ]

Be Humble... Be Nice.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The Oracle driver need to be on your application's classpath.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
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

Joined: Nov 10, 2007
Posts: 627
Any Help Guys?/

Thanks.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
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

Joined: Aug 05, 2007
Posts: 294
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

Joined: Nov 10, 2007
Posts: 627
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

Joined: Apr 28, 2009
Posts: 2
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

Joined: Dec 20, 2006
Posts: 2501
    
    8

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............ "





OCUP UML fundamental and ITIL foundation
youtube channel
JIA Jerry
Greenhorn

Joined: Apr 28, 2009
Posts: 2
Hi there
I fixed the problem by replacing the jdbc file.

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

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Installed Oracle 10g in my Local system and now I am having problem connecting to it