Thursday, May 30, 2019

UiPath - Connect to Oracle database






This error generally occurs if you are using the 64 bit Oracle client. As UiPath is a 32 bit application, this issue is occurring. Please make sure that you have 32 bit oracle client installed. Please visit the below links for more insights-

Download 32bit client for ODBC here:
https://www.oracle.com/in/database/technologies/instant-client/microsoft-windows-32-downloads.html








Follow below link to setup the instant client:


Go to C:\Windows\SysWOW64\odbcad32 Application and add  ODBC connection.


https://stackoverflow.com/questions/9002560/oracle-client-and-networking-components-were-not-found
https://superuser.com/questions/939752/microsoft-odbc-driver-cant-find-oracle-instant-client






https://forum.uipath.com/t/how-to-connect-to-oracle-database/2925/3

https://youtu.be/cZDDI9HFBIU


Make sure you have  tnsnames.ora & sqlnet.ora in C:\oracle_odbc

Add TNS_ADMIN - system_path
Add Path - C:\oracle_odbc to existing Path

Use -  TOAD to generate sqlnet.ora file  ->


###############################################################
#
# This file is automatically generated by AutoConfig.  It will be read and
# overwritten.  If you were instructed to edit this file, or if you are not
# able to use the settings created by AutoConfig, refer to Metalink Note
# 387859.1 for assistance.
#
#$Header: NetServiceHandler.java 120.19.12010000.6 2010/03/09 08:11:36 jmajumde ship $
#
###############################################################

SQLNET.INBOUND_CONNECT_TIMEOUT =60
DIAG_ADR_ENABLED=ON



IFILE=/u01/app/oracle/product/11.2.0.4/network/admin/sqlnet_ifile.ora
NAMES.DIRECTORY_PATH=(TNSNAMES, ONAMES, HOSTNAME)
SQLNET.EXPIRE_TIME=10
TRACE_FILELEN_CLIENT=100
TRACE_FILENO_CLIENT=3
TRACE_LEVEL_CLIENT=OFF
TRACE_TIMESTAMP_CLIENT=ON
TRACE_UNIQUE_CLIENT=ON
USE_DEDICATED_SERVER=OFF





Download 32 bit driver here:
https://www.oracle.com/database/technologies/112010-win32soft.html










Thursday, May 23, 2019

Get the return value from java method by shell script

1
2
3
4
5
public class Test {
    public static void main (String args []) {
        System.out.println ("scuccess");
    }
}

So save this, compile it, run it: 

Tuesday, May 21, 2019

Give permission to execute Shell Script ; UNIX

chmod 0755 TestBash.sh






TestBash.sh contents are here
---------------
#!/bin/sh
java HelloWorld
result=$?
echo $result


Gets result from java to shell script----->https://www.chrisnewland.com/java-return-code-in-linux-shell-script-122

if  an error -  bad interpreter: No such file or directory


use below - 

$ sed -i -e 's/\r$//' TestBash.sh &

Friday, May 3, 2019

Setup build file with Ant Script ; JAVA

<project name="DLWSJavaSample" default="compile" basedir=".">
    <property file="build.properties" />
    <path id="lib.classpath">
        <fileset dir="${dir.lib}">
            <include name="*.jar" />
        </fileset>
        <fileset dir="${dir.lib.cli}">
            <include name="*.jar" />
        </fileset>
    </path>

    <!-- =================================================================== -->
    <!-- Clean the build directory                                           -->
    <!-- =================================================================== -->
    <target name="clean" description="Cleanup build artifacts">
        <delete dir="${dir.generated}" />
    </target>

    <!-- =================================================================== -->
    <!-- Prepare the build directory                                         -->
    <!-- =================================================================== -->
    <target name="setup" description="Prepare for build" depends="clean">
        <mkdir dir="${dir.generated}" />
        <mkdir dir="${dir.generated.java}" />
        <mkdir dir="${dir.generated.classes}" />
    </target>

    <!-- =================================================================== -->
    <!-- wsimport to generate the client stubs from the WSDL                 -->
    <!-- =================================================================== -->
    <target name="genclient" description="Generate stubs from the WSDL" depends="setup">
        <exec executable="${java.home}/../bin/wsimport">
            <arg line="-keep -d ${dir.generated.java} -extension -p com.bm.datalic.dlws.stubs ${dir.config.wsdl}" />
        </exec>
    </target>

    <!-- =================================================================== -->
    <!-- Compile the sample code     (stubs already compiled)                -->
    <!-- =================================================================== -->
    <target name="compile" description="Compile DLWS Sample Code" depends="genclient">
        <javac destdir="${dir.generated.classes}" classpathref="lib.classpath" debug="on" includeantruntime="false">
            <src path="${dir.src}" />
            <src path="${dir.generated.java}" />
        </javac>
    </target>

    <!-- =================================================================== -->
    <!-- Run (replace ${sampleName} and ${programFlag} appropriately)        -->
    <!-- =================================================================== -->
    <target name="run" description="Run DLWS Sample Code" depends="compile">
        <java fork="true" classname="com.bm.datalic.dlws.PerSecurity">
            <arg line="-s ${sampleName} -p ${programFlag}" />

            <classpath>
                <path refid="lib.classpath" />
            </classpath>
            <classpath location="${dir.generated.classes}" />
        </java>
    </target>
</project>

Run built JAVA program on linux with dependent jar files

/myapp/WL12c/app/oracle/jdk1.8.0_211/bin/java -cp /home/app/ERApp/lib/commons-cli-1.4/commons-cli-1.4.jar:/home/myapp/ERApp/lib/ojdbc14.jar: com.bloomburger.datalic.dlws.PerSecurity -s GetAllExRates -p scheduled &>>output.txt &


Explanation:

java installed location -> /app/WL12c/app/oracle/jdk1.8.0_211/bin/java

classpath or dependent jar locations-> -cp /home/app/ExchangeRatesApp/lib/commons-cli-1.4/commons-cli-1.4.jar:/home/app/ERApp/lib/ojdbc14.jar

in the generated classes folder-> com.bloomburger.datalic.dlws.PerSecurity (make sure you get to the folder where com(com.bloomberg.datalic.dlws.PerSecurity) exists and run above command in blue color)

Pass Arguments to the java class file : -s GetAllExRates -p scheduled

Save the logs to file exit with background running enable -> &>>output.txt &