Re: How to do a local connection with JDBC ?

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 18 Jan 2005 03:50:42 -0800
Message-ID: <1106049042.412482.258580_at_z14g2000cwz.googlegroups.com>


jodetek wrote:
> Hi,
>
> I'm using IBM AIX 4.3.3 ML11 (3 Bits), with IBM's Java 1.3.0
> Oracle 8.1.7.4 and the Oracle JDBC driver classes12.zip
>
> When I perform the following connection:
>
> DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver()
);
> conn = DriverManager.getConnection (
> "jdbc:oracle:oci8:arkernel/arkernel_at_ARDEV1");
>
> Then, the oracle process created for my batch is not in local and
therefore
> uses SQL*Net.
>
> ARDEV1-../jdbc/sample> ps auxww | grep oracle | grep ARDEV1
> oracle 45908 0.0 1.0 28480 14244 - A 19:26:41 0:00 oracleARDEV1
(LOCAL=NO)
>
>
> It's not good for performance
>
> Now, If I perform the following connection:
>
> DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver()
);
> conn = DriverManager.getConnection (
"jdbc:oracle:oci8:arkernel/arkernel_at_");
>
>
> (nothing after the _at_, as it is shown in the Oracle documentation)
>
> The connection used the $ORACLE_SID environment variable and the
session is
> local and that is much better for the performance.
>
>
> jdelfoss 28644 0.0 1.0 28480 14284 - A 19:24:31 0:00 oracleARDEV1
> (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)
> ))
>
>
>
>
> Now come the problem...
>
>
> I run exactly the same program with IBM's Java 1.3.1 (instead of
1.3.0) (and
> nothing after the _at_ to be in local)
>
> I got the following error
>
> exception: ORA-01034: ORACLE not available
> ORA-27123: unable to attach to shared memory segment
> IBM AIX RISC System/6000 Error: 22: Invalid argument
>
> while the same connection is working with sqlplus and the database is
> running. Is it a bug ?
>
> With Java 1.3.1, it's only working using SQL*Net (_at_ARDEV1)
>
> Here is the question: What is the correct way to connect to a
database in
> local (the java batch is running on the same server than the
database) ? We
> don't want to use SQL*Net !
>
>
>
> Thanks for any help
>
> JD

I don't have 1.3.0 or 1.3.1 to test this but you can force SQL*Net to make a local connection. In your tnsnames.ora you can specify BEQ protocol e.g.

ARDEV1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = BEQ)(PROGRAM = oracle)(ARGV0 = oracleARDEV1)(ARGS =
'(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))')) (CONNECT_DATA = (SERVICE_NAME = ARDEV1)) )

then you can use the connect string
jdbc:oracle:oci8:arkernel/arkernel_at_ARDEV1 and still make local connection.

BTW... what's the performance gain... in time? I doubt it's going to be much unless your connection goes around the world before hitting the listener.

Regards
/Rauf Received on Tue Jan 18 2005 - 12:50:42 CET

Original text of this message