Posts

Showing posts with the label BEQ

Bypassing the Listener and Connecting the Instance without a Password from Java Code

Image
In the past I wrote a post about  Bypassing the listener and connecting to ASM without a password from Python code Now, I've been asked to prove that it can be done in Java. The solution is almost the same. Java sample code using OCI: $ vi OracleCon.java import java.sql.*; class OracleCon {     public static void main(String args[]) {         try {             Class.forName("oracle.jdbc.driver.OracleDriver");             Connection con = DriverManager.getConnection(                 "jdbc:oracle:oci:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=BEQ) (PROGRAM=oracle) (ARGV0=oracle+ASM) (ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))') (ENVS = 'ORACLE_HOME=/oracle/product/12.1.0.2/grid,ORACLE_SID=+ASM'))) (CONNECT_DATA= (SID=+ASM)))", "sys as sysdba", "change on install");             Statement...

Bypassing the listener and connecting to ASM without a password from Python code

Image
Requirement I was asked to have smart code that can connect to a local ASM instance without the need for any prior preparations like setting up the listener or any other changes in the database. And even do this without a password! Problems Listener If there is already a listener that uses the default port (i.e. 1521 ), the ASM can register itself dynamically to the listener with no need to configure anything. But on systems that use ports other than 1521 , the listener is not registered automatically. We could set the parameter LOCAL_LISTENER like this: SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.40)(PORT=1521))'; But, I was asked to do no prior configuration . Password Using SQL*Plus we have the option to connect to the database locally Using Password File Authentication with no need to setup a listener and without using a password in the connection string. $ export ORACLE_SID=+ASM $ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0...