Tuesday 7 July 2020

locate: command not found

1. Install mlocate-0.26-8.el7.x86_64.rpm & findutils-4.5.11-6.el7.x86_64
2. Run "updatedb"
3. Now run the locate command

Thursday 2 July 2020

SQL Client Installation on Linux machine

Solution:

1. Install below two RPMs

    oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

    oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

 

2. Create the SQL.env file using below

 

ORACLE_HOME=/usr/lib/oracle/12.2/client64

PATH=$ORACLE_HOME/bin:$PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_HOME

export LD_LIBRARY_PATH

export PATH

 

3. Source the SQL.env file


4. Connection can be established using either SID/SERVICE name as below

  • Connect using SERVICE name: sqlplus "username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= <hostname>)(PORT=1531))(CONNECT_DATA=(SERVICE_NAME=<SERVICE_NAME>)))"
  • Connect using SID name: sqlplus "username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= <hostname>)(PORT=1531))(CONNECT_DATA=(SID=<SID_NAME>)))"
Note: To use the import/export utility on instant client install rpm oracle-instantclient12.2-tools-12.2.0.1.0-1.x86_64.rpm

Monday 25 May 2020

JDBC Connectivity Testing in Linux command Line

Pre-req:
1. Download ojdbc8.jar from oracle website.
2. Compatability of Java, Database, JDBC are in below note id
    Starting With Oracle JDBC Drivers - Installation, Certification, and More! (Doc ID 401934.1)

Step-1:

Create the java file JDBCConnectivity.java as below code

import java.sql.*;
 class JDBCConnectivity{
     public static void main(String args[]) throws SQLException {
         Connection con = null;
         try{
             Class.forName("oracle.jdbc.driver.OracleDriver");
             String DatabaseURL = "jdbc:oracle:thin:@//<Hostname/Database IP Address>:<Port Number>/<Database Service Name>";
             System.out.println("jdbcurl=" + DatabaseURL);
             String UserName = "<Username>";
             String UsrPassword = "<Password>";
             con=DriverManager.getConnection(DatabaseURL,UserName,UsrPassword);
             System.out.println("Connected to the database Successfull.");
             Statement stmt=con.createStatement();
             System.out.println("Executing query");
             ResultSet rs=stmt.executeQuery("SELECT 1 FROM DUAL");
             while(rs.next())
                 System.out.println(rs.getInt("1"));
             con.close();
         }catch(Exception e){ System.out.println(e);}
         finally {
             con.close();
         }
 }
 }

Step-2:
Compile the java code

javac JDBCConnectivity.java

Step-3:

Run the java code using below command

java -Djava.security.egd=file:/dev/../dev/urandom -cp ojdbc8.jar:. JDBCConnectivity

Tuesday 18 February 2020

DB : [INS-20802] Oracle Net Configuration Assistant failed

Error:

When we check the installation logfile we can find below error log

[FATAL] [DBT-06103] The port (5,500) is already in use.
   ACTION: Specify a free port.
Oracle Database Configuration Assistant failed.
Starting 'Oracle Database Configuration Assistant'
[FATAL] [DBT-06103] The port (5,500) is already in use.
   ACTION: Specify a free port.
Oracle Database Configuration Assistant failed.
Starting 'Oracle Database Configuration Assistant'
[FATAL] [DBT-06103] The port (5,500) is already in use.
   ACTION: Specify a free port.

Solution:

When you ping your hostname it will not be reachable

[oracle@testdb] ping testdb
ping: testdb : Name or service not known

Add the full hostname entry in /etc/hosts file & retry the database installation

192.168.1.1 testdb.local.com testdb

Monday 6 January 2020

Python : Dummy service on 9999 port in Linux

#!/usr/bin/python
# Demo server to open port 9999
# Modified from Python tutorial docs
import socket
import sys
HOST = 'localhost'   # IP addresses or Hostname
PORT = 9999 # Open non-privileged port 9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created Successfully'
#Bind socket to local host and port
try:
    s.bind((HOST, PORT))
except socket.error as msg:
    print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()
print 'Socket bind complete'
#Started listening on socket
s.listen(10)
print 'Socket now listening'
while 1:
    #waiting to accept a connection - blocking call
    conn, addr = s.accept()
    print 'Connected with ' + addr[0] + ':' + str(addr[1])
s.close()

save the above file as port_server.py

run the port_server.py in one terminal & try telnet the hostname with 9999

SQL Developer displaying Junk characters (??????)

Change the Encoding in SQL Developer Preferences as below Tools --> Preferences --> Environment --> Encoding --> UTF...