jQuery in Action, 3rd edition
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\classes111.zip [ i have one more zip file there in the lib folder by name classes102.zip ]. 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.io.*;
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 (rset.next ())
// 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 http://technet.oracle.com/doc/oracle8i_816/network.816/a76933/listener.htm#475293
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 http://technet.oracle.com/doc/oracle8i_816/java.816/a81354/basic1.htm#1004483
Also, while you can use classes111.zip with jdk1.2, you should probably upgrade to classes12.zip.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: JDBC Connectivity
It's not a secret anymore!