Posts

Showing posts from June 7, 2016

calling function in groovy

To call sql function in groovy
def encryptAccountInformation(number1, keyId) {
def encryptedValue
Sql sql = null
try{
if (accNumber && keyId){
sql = new Sql(dataSource)
sql.call("{? = call TEST_FN_XYZ(?,?)}",[
Sql.VARCHAR,
accNumber,
keyId
]){ result -> encryptedValue = result }
}
} catch (Exception e){
log.error( "Error getting Encryption data " + e)
} finally{
if(sql) sql.close()
}
return encryptedValue
}

Call procedure in groovy

sql = new Sql(dataSource_nss)
println"After Datasource"
def stmt = "BEGIN PKG_REFLOAD_SOURCE.PRC_VALIDATE_INSERT_SOURCE(?,?,?,?,?); END;" 

def params = [
itemName,
ItemtId,
user,
Sql.NUMERIC,
Sql.resultSet(OracleTypes.CURSOR)
]


sql.call (stmt, params) { status,errors ->

if(status==1){
errors.eachRow(){
def erroObj
erroObj = [
field:errors[0],
desc:errors[1]
]
println" error value record :"+erroObj
lstErrors << erroObj
}
}
}



Giving Permisson & setting JAVA_HOME in unix

for giving permisson
 chmod u+x processName
Set JAVA HOME in UNIX in different shell
To set JAVA_HOME, do one of the following:
For Korn and bash shells, run the following commands:export JAVA_HOME=jdk-install-direxport PATH=$JAVA_HOME/bin:$PATHFor the bourne shell, run the following commands:JAVA_HOME=jdk-install-direxport JAVA_HOMEPATH=$JAVA_HOME/bin:$PATHexport PATHFor the C shell, run the following commands:setenv JAVA_HOME jdk-install-dirsetenv PATH $JAVA_HOME/bin:$PATHexport PATH=$JAVA_HOME/bin:$PATH

Print All Request Parameter in java

To Print all Request Parameter of a HTTP request
java.util.Enumeration enu = request.getParameterNames();
while(enu.hasMoreElements()){
String paramName = (String)enu.nextElement();
System.out.println("PARAM: "
+ paramName
+ ": "
+ request.getParameter(paramName));
}

Inner classes & anonymous in java

Its block inside a class & behave as member of class.It doesn't just under package but under class of a package.Inner class have access to all members of outer class.
class class{            inner class{                  } }
It not required to make an instance of an inner class in order to have an instance of the outer class but to get instance of inner class we need to create instance of outer class & via it we can create instance of inner class.


Inner class type
Static ( inner class having static modifer) Member inner class ( normal class inside class)
Method Local ( inner class defined inside a method  of class) Anonymous  ( inner class having no name)


1. Member inner class

From inside outer class inner class can be access like normal class see example as below.


//outer class declaration
class MyOuterClass { private int i = 18;
// Creating instance of inner class and calling inner class function

public void createInnerInstance() {
// access inner class as normal if you are unde…