File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC Connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC Connectivity" Watch "JDBC Connectivity" New topic

JDBC Connectivity

Swaminathan Ramanathan

Joined: Sep 23, 2000
Posts: 8
Hello Everyone !
I'm trying to connect to Oracle from Java. I've given my coding below. But i get an error. The error is " Connection Refused No further Information". How do go about now ? Is my coding alright ? I set my classpath to c:\orawin95\jdbc\lib\ [ i have one more zip file there in the lib folder by name ]. I have both jdk1.2.2 and 1.3. But here i used 1.2.2. I use Oracle 8.0.3. Somebody help me out of this prob.
This is the coding i used :
import java.sql.*;
import java.util.Date;
class JdbcTest
public static void main (String args [])
throws SQLException, IOException
System.out.println ("Loading Oracle driver");
Class.forName ("oracle.jdbc.driver.OracleDriver");
catch (ClassNotFoundException e)
System.out.println ("Could not load the driver");
e.printStackTrace ();
System.out.println ("Connecting to the local database");
Connection conn = null;
try {
conn =
("jdbc racle:thin:scott/tiger");
catch (Exception e)
System.out.println("Error : " + e.getMessage());

Statement stmt = conn.createStatement ();
// Query the employee names
ResultSet rset = stmt.executeQuery ("select ename from emp");
while ( ())
// Print the name out
System.out.println (rset.getString (1));

Is there any problem with my connection specification like the thin driver ? Do help me.
Thanks and Regards.

[This message has been edited by Swaminathan Ramanathan (edited January 22, 2001).]
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
To use the thin driver, there must a database listener configured and listening. See
The other thing that appears to be wrong is the database url. In addition to the username and password, the url for a thin driver needs to include the host and port:
Where host is the name of the machine where the database listener is listening for connections and sid is the System Identifier for the database. See
Also, while you can use with jdk1.2, you should probably upgrade to
I agree. Here's the link:
subject: JDBC Connectivity
It's not a secret anymore!