Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help with Setting up Oracle 7 with Oracle JDBC???

Re: Help with Setting up Oracle 7 with Oracle JDBC???

From: Morten Primdahl <morten_at_caput.com>
Date: Thu, 09 Dec 1999 10:15:09 +0100
Message-ID: <384F731D.902A190B@caput.com>

Can you connect to the DB using SQLPlus? If so, it's probably the TNS listener that's not up. JDBC connects through a URL, usually port 1521 of the Oracle host machine. What I usually do is keep a property file with the following:

db.user   = <username>
db.passwd = <password>
db.driver = oracle.jdbc.driver.OracleDriver
db.url    = jdbc:oracle:thin:@machine.domain.top:1521:SID

I read the file into a Properties object at startup and connect to the DB like (just declare the proper variables)

public void init(Properties props)
{

  this.user   = props.getProperty("db.user");
  this.passwd = props.getProperty("db.passwd");
  this.driver = props.getProperty("db.driver");
  this.url    = props.getProperty("db.url");

  try {
    Class.forName(driver);
  }
  catch(ClassNotFoundException x) {
    System.out.println("Could not load the driver : "+driver);     System.exit(0);
  }                 

  info = new java.util.Properties();
  info.put("user", user);
  info.put("password", passwd);                 

  try {
    connection = createConnection(url, info);   }
  catch(SQLException x) {
    System.out.println("Error connecting to database -> '"+url+

                       "' as "+user+"/"+passwd+"\n");
    x.printStackTrace();
    System.exit(0);
  }
}

Anyway, if you can connect to the DB normally, I guess it's the TNS listener, you can restart it (UNIX) with:

bash$ lsnrctl start

Hope this helps

Morten

mattsullivan_at_my-deja.com wrote:
>
> Hello all,
>
> I am trying to communicate with an Oracle 7 NT database using the
> Oracle JDBC classes (classes111.zip). The problem is that I just cant
> get the connection to go through.
>
> All I keep getting is the following error (whether it is run on the
> same machine as Oracle or not).
>
> 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)
>
> Are there any step-by-step guides out there on how to set up Oracle and
> the classes so this will work? A few examples of this?
>
> Thanks,
>
> Matt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--

Morten Primdahl		Caput ApS	Tel +45 33 12 24 42		
morten_at_caput.com	Nygade 6	Fax +45 33 91 24 42
http://www.caput.com	DK-1164 Kbh K
Received on Thu Dec 09 1999 - 03:15:09 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US