Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

help me connecting to oracle8 P.E.

  Asked By: Dora    Date: Apr 01    Category: Java    Views: 886
  

I am trying to connect oracle8 Personal Edition with
JDBC. following is my code.

/**********************************************/
import java.sql.*;
public class sample
{
public static void main(String arg[])
{
try
{
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
Connection con=
DriverManager.getConnection("jdbc:oracle:thin:@Sanjeev:1521:ORCL","scott","tiger\
");
Statement smt = con.createStatement();
ResultSet rs = smt.executeQuery("SELECT * FROM
EMP");
while (rs.next())
{
System.out.println(rs.getString(1));
}
con.close();
}
catch (SQLException e)
{
System.out.println("\nerror !!!!\n" + e);
}
}
}
/**************************************/



This code compiles successfully. it throws an
Exception at runtime.


error !!!!
java.sql.SQLException: Connection refused: no further
information


plz. see what is the problem. i am using WIN98,
JDK1.2.2, oracle8.0 personal edition.
is there any problem in code or i need some other
drivers for my platfors, if so where can i find them.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Maria Miller     Answered On: Apr 01

You need to make sure that Oracle is started and running.

 
Answer #2    Answered By: Elias Turner     Answered On: Apr 01


Instead of

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

use

Class.forName("oracle.jdbc.driver.OracleDriver");

as this loads the class  explicitly - see

java.sun.com/.../driverma
nager.doc.html

This will also let you know if the driver  can't be found.

Also check that the path to the jar containing the Driver is in the
Java runtime classpath, something like

java -cp .;%ORACLE_HOME%/ora81/jdbc/lib/classes111.jar MyClass

(replace %ORACLE_HOME% with the oracle  folder)

 
Didn't find what you were looking for? Find more on help me connecting to oracle8 P.E. Or get search suggestion and latest updates.




Tagged: