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

Home -> Community -> Usenet -> c.d.o.server -> Re: A little help connecting to oracle from java. Anyone? Please!!? :-)

Re: A little help connecting to oracle from java. Anyone? Please!!? :-)

From: <a_at_a.com>
Date: Mon, 12 Aug 2002 6:36:28 +0800
Message-ID: <01HW.B97D07EC002B0EB41DF57FA8@enews.newsguy.com>


On Sun, 11 Aug 2002 21:21:21 +0800, Sybrand Bakker wrote (in message <ulcqa9f3sffa79_at_corp.supernews.com>):

>
> "Simon Harvey" <noThanks_at_pdf.com> wrote in message
> news:3d563604_7_at_news.teranews.com...

>> Another thing that might provide a clue to this is that I can connect

> using
>> SQL Plus with the name dayton but not the name dayton.homenet. Shouldnt I

> be
>> able to do both. I'm sitting at the machine which has oracle on it.
>> Just as a reminder my tnsnames entry is:
>> 
>> 
>> DAYTON =
>> (DESCRIPTION =
>> (ADDRESS_LIST =
>> (ADDRESS = (PROTOCOL = TCP)(HOST = aegis)(PORT = 1521))
>>> 
>> (CONNECT_DATA =
>> (SERVICE_NAME = dayton.homenet)
>>> 
>>> 
>> 
>> Thanks
>> Simon
>> 
>> 

>
> No.
> The service name meant is the tnsnames service_name
> the syntax for a tns entry is
>
> service_name = ...
> Your service name is dayton
>
> Your jdbc connection string is wrong.
> The hostnames need to be identical and translate to the same IP-address.
> Either you use 'aegis' in listener.ora *and* the jdbc connection string *OR*
> you use 'localhost' in listener.ora *and* the jdbc connection string.
> A mix is NOT going to work.
>
> As the error now is very obvious, I would recommend anyone with net8
> problems to provide as much detail as you can (ie listener.ora, sqlnet.ora,
> tnsnames.ora) *rightaway on your first post*.
> With sufficient detail provided initially this would also have been resolved
> with the first post.
>
> Regards
>
>
> --
> Sybrand Bakker
> Senior Oracle DBA
>
> to reply remove '-verwijderdit' from my e-mail address
>
>
>

ok here is some code that will get you cvonnected to hte oracel database it returns a connection handle.

    public static Connection getConnectionUsingDriverManager() throws Exception {

        Class.forName(JDBC_DRIVER);
        Connection conn = DriverManager.getConnection(DB_URL, DB_USER, 
DB_PWD);
        conn.setAutoCommit(false);
        return conn;

    }
    static String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";     static String DB_URL = "jdbc:oracle:thin:@ipaddress/dns name:1521:orcl";     
  		static String DB_PORT=":1521:orcl";
    static String DB_USER = "user name in here";
    static String DB_PWD = "password in here";
Received on Sun Aug 11 2002 - 17:36:28 CDT

Original text of this message

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