This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Oracle 7 and JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle 7 and JDBC" Watch "Oracle 7 and JDBC" New topic
Author

Oracle 7 and JDBC

Chong YK
Greenhorn

Joined: Sep 05, 2001
Posts: 1
Hi all,
I am trying to connect the java program to Oracle 7.It gives the following error message when i tried to run it on my Win98. I am using jdk1.2.2 and the oracle driver is classes111.zip. My host and sid r based on the sid and port number in the TNSNAMES.ora.My testing code is as below:
import java.sql.*;
public class TestConnect {
public static void main (String[] arg) {
String url="jdbcracle:thin:@127.0.0.1:1521:ORCL";
String userId = "scott";
String password ="tiger";
//Load the driver
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
}
catch (ClassNotFoundException e){
System.out.println("Could not load the driver");
System.exit(0);
}

//Request the connection
Connection con = DriverManager.getConnection(url,userId, password );

con.close();
System.out.println("All okay");
}
catch (Exception e) { e.printStackTrace();}

}
}

Run-time error message:
java.sql.SQLException: Connection refused: no further information
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:230)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:110)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:148)
at java.sql.DriverManager.getConnection(DriverManager.java:457)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at TestConnect.main(TestConnect.java:25)
I've checked the message boards but cant find any solution...
I am greatly thankful if any of you out there can give some idea or solutions on the problem!...
Thanks...
YK
mibrahim
Greenhorn

Joined: Jul 10, 2001
Posts: 3
I guess you are trying to connect to an oracle instance running on the local machine (127.0.0.1) from where you are trying to connect. Is this oracle instance running?
If you are not running the database on the machine from where you are trying to connect, change the ip to point to the remote machine and try again.
 
Consider Paul's rocket mass heater.
 
subject: Oracle 7 and JDBC