Commit 7b303039 authored by manohar's avatar manohar

changes related connection closing in various components


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91079 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cff214cb
...@@ -10,9 +10,10 @@ import ibase.webitm.ejb.*; ...@@ -10,9 +10,10 @@ import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.system.config.*; import ibase.system.config.*;
import ibase.system.config.ConnDriver;
public class GenVal public class GenVal
{ {
Connection conn = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
...@@ -30,11 +31,13 @@ public class GenVal ...@@ -30,11 +31,13 @@ public class GenVal
String logDirName = ""; String logDirName = "";
//end added by msalam on 22/11/07 for appending log in jboss log //end added by msalam on 22/11/07 for appending log in jboss log
public String genVal(String modName ,String objContext,Document data ,Connection conn) //public String genVal(String modName ,String objContext,Document data ,Connection conn)
public String genVal(String modName ,String objContext,Document data )
{ {
//System.out.println("Generalized Validation Is In Process.************************************......."); //System.out.println("Generalized Validation Is In Process.************************************.......");
Statement stmt = null; Statement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null;
String fldName ="",valType = "",fldMin = "",sqlInput = "",fldMax = "",errCD = "",blankOpt = "",fldData ="",fldType=""; String fldName ="",valType = "",fldMin = "",sqlInput = "",fldMax = "",errCD = "",blankOpt = "",fldData ="",fldType="";
String errCode =""; String errCode ="";
String sql = " SELECT FLD_NAME,VAL_TYPE,FLD_MIN,SQL_INPUT,FLD_MAX,ERROR_CD,BLANK_OPT ,FLD_TYPE FROM GENMST WHERE MOD_NAME= '"+modName.toUpperCase()+"'"; String sql = " SELECT FLD_NAME,VAL_TYPE,FLD_MIN,SQL_INPUT,FLD_MAX,ERROR_CD,BLANK_OPT ,FLD_TYPE FROM GENMST WHERE MOD_NAME= '"+modName.toUpperCase()+"'";
...@@ -42,6 +45,10 @@ public class GenVal ...@@ -42,6 +45,10 @@ public class GenVal
String errMsg =" "; String errMsg =" ";
try try
{ {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
stmt = conn.createStatement(); stmt = conn.createStatement();
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
while (rs.next()) while (rs.next())
...@@ -77,7 +84,8 @@ public class GenVal ...@@ -77,7 +84,8 @@ public class GenVal
//cross query validation //cross query validation
if (valType.equalsIgnoreCase("Q")) if (valType.equalsIgnoreCase("Q"))
{ {
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn ); //***errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn );
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD );
} }
//slab validation //slab validation
else if( valType.equalsIgnoreCase( "S" ) ) else if( valType.equalsIgnoreCase( "S" ) )
...@@ -139,7 +147,8 @@ public class GenVal ...@@ -139,7 +147,8 @@ public class GenVal
else if( valType.trim().equalsIgnoreCase("M") ) else if( valType.trim().equalsIgnoreCase("M") )
{ {
//System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]"); //System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]");
errMsg = masterVal( fldName, modName, fldData, errCD, conn ); //***errMsg = masterVal( fldName, modName, fldData, errCD, conn );
errMsg = masterVal( fldName, modName, fldData, errCD );
} }
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also //next line commented by msalam on 22/11/07 as validation is required on fldData blank also
}//end of blank opt N }//end of blank opt N
...@@ -151,11 +160,22 @@ public class GenVal ...@@ -151,11 +160,22 @@ public class GenVal
break; break;
} }
} }
if(errMsg.trim().length()==0 && xFlag == true) rs.close();
rs = null;
stmt.close();
stmt = null;
if (conn != null)
{
conn.close();
conn = null;
}
if(errMsg.trim().length()==0 && xFlag == true)
{ {
xFlag = false; xFlag = false;
//System.out.println("Calling genVal for module * * * * * [X]"); //System.out.println("Calling genVal for module * * * * * [X]");
errMsg = genVal("X",objContext,data ,conn); //***errMsg = genVal("X",objContext,data ,conn);
errMsg = genVal("X",objContext,data );
xFlag = true; xFlag = true;
} }
} // end of try } // end of try
...@@ -176,13 +196,15 @@ public class GenVal ...@@ -176,13 +196,15 @@ public class GenVal
{ {
try try
{ {
if(stmt!=null) if(rs !=null)
{ {
stmt=null; rs.close();
rs=null;
} }
if(rs !=null) if(stmt!=null)
{ {
rs=null; stmt.close();
stmt=null;
} }
if (conn != null) if (conn != null)
{ {
...@@ -204,7 +226,8 @@ public class GenVal ...@@ -204,7 +226,8 @@ public class GenVal
//changed by msalam on 26/09/07 start //changed by msalam on 26/09/07 start
//to overload the function //to overload the function
//public String genVal(String modName ,String objContext,Document data ,Connection conn) //public String genVal(String modName ,String objContext,Document data ,Connection conn)
public String genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn) //public String genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
public String genVal(String modName ,String objContext,Document data, String focusedRow)
{ {
String errMsg =" "; String errMsg =" ";
//changed by msalam on 26/09/07 start //changed by msalam on 26/09/07 start
...@@ -228,7 +251,8 @@ public class GenVal ...@@ -228,7 +251,8 @@ public class GenVal
//System.out.println("--------------------------------------->GenVal called"); //System.out.println("--------------------------------------->GenVal called");
writeLog( filePtr, "GenVal called", true ); writeLog( filePtr, "GenVal called", true );
//end changed by msalam on 22/11/07 for appending log //end changed by msalam on 22/11/07 for appending log
errMsg = genVal( modName, objContext, data, conn); //***errMsg = genVal( modName, objContext, data, conn);
errMsg = genVal( modName, objContext, data);
return errMsg; return errMsg;
} }
...@@ -267,15 +291,24 @@ public class GenVal ...@@ -267,15 +291,24 @@ public class GenVal
return result; return result;
} }
//master validation //master validation
private String masterVal( String fldName, String modName, String fldData, String errCD, Connection conn ) //private String masterVal( String fldName, String modName, String fldData, String errCD, Connection conn )
private String masterVal( String fldName, String modName, String fldData, String errCD )
{ {
String err = " "; String err = " ";
Statement mst = null; Statement mst = null;
ResultSet mrs = null; ResultSet mrs = null;
Connection conn = null;
int count=0; int count=0;
String sql =""; String sql ="";
writeLog( filePtr, "fldData:::::::::"+fldData, true ); writeLog( filePtr, "fldData:::::::::"+fldData, true );
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
//System.out.println("fldData:::::::::"+fldData); //System.out.println("fldData:::::::::"+fldData);
//next 2 lines commented by msalam on 23/11/07 as validation is required on fldData blank also //next 2 lines commented by msalam on 23/11/07 as validation is required on fldData blank also
//if( fldData != null && fldData.trim().length()!=0 ) //if( fldData != null && fldData.trim().length()!=0 )
...@@ -291,19 +324,25 @@ public class GenVal ...@@ -291,19 +324,25 @@ public class GenVal
} }
writeLog( filePtr, "Excecuting Query(valtype=M);:::::::::::::::"+sql, true ); writeLog( filePtr, "Excecuting Query(valtype=M);:::::::::::::::"+sql, true );
//System.out.println("Excecuting Query(valtype=M);:::::::::::::::"+sql); //System.out.println("Excecuting Query(valtype=M);:::::::::::::::"+sql);
try //try
{ //{
mst=conn.createStatement(); mst=conn.createStatement();
mrs = mst.executeQuery( sql ); mrs = mst.executeQuery( sql );
if(mrs.next()) if(mrs.next())
{ {
count = mrs.getInt(1); count = mrs.getInt(1);
} }
mrs.close();
mrs = null;
mst.close();
mst = null;
if(count==0) if(count==0)
{ {
err = errCD; err = errCD;
writeLog( filePtr, "Master validation record Not Found", true ); writeLog( filePtr, "Master validation record Not Found", true );
} }
conn.close();
conn = null;
} }
catch(Exception e){e.printStackTrace();} catch(Exception e){e.printStackTrace();}
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also //next line commented by msalam on 22/11/07 as validation is required on fldData blank also
...@@ -314,7 +353,8 @@ public class GenVal ...@@ -314,7 +353,8 @@ public class GenVal
return err; return err;
} }
private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd, Connection conn ) //private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd, Connection conn )
private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd )
{ {
//System.out.println( "Result Should come as " + resultStr ); //System.out.println( "Result Should come as " + resultStr );
writeLog( filePtr, "Result Should come as " + resultStr, true ); writeLog( filePtr, "Result Should come as " + resultStr, true );
...@@ -327,6 +367,7 @@ public class GenVal ...@@ -327,6 +367,7 @@ public class GenVal
StringTokenizer st = null; StringTokenizer st = null;
String data=""; String data="";
String errCode =" "; String errCode =" ";
Connection conn = null;
String colType =""; String colType ="";
try try
{ {
...@@ -471,6 +512,9 @@ public class GenVal ...@@ -471,6 +512,9 @@ public class GenVal
//Changed by msalam on 22/10/07 for colType = "DATETIME" end //Changed by msalam on 22/10/07 for colType = "DATETIME" end
} }
} }
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
writeLog( filePtr, "After replace parameter Final Query[*********]:::" + QueryBuf.toString(), true ); writeLog( filePtr, "After replace parameter Final Query[*********]:::" + QueryBuf.toString(), true );
pstmt1= conn.prepareStatement( QueryBuf.toString() ); pstmt1= conn.prepareStatement( QueryBuf.toString() );
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
...@@ -517,6 +561,12 @@ public class GenVal ...@@ -517,6 +561,12 @@ public class GenVal
dataVec.add( data ); dataVec.add( data );
} }
} }
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
conn.close();
conn = null;
for( int counter = 0; counter < resultStrVec.size(); counter++ ) for( int counter = 0; counter < resultStrVec.size(); counter++ )
{ {
String result = (String)resultStrVec.get( counter ); String result = (String)resultStrVec.get( counter );
......
...@@ -35,11 +35,11 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -35,11 +35,11 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
{ {
Connection conn = null; //Connection conn = null;
String sql = null; //String sql = null;
PreparedStatement pstmt = null; //PreparedStatement pstmt = null;
ResultSet rs = null; //ResultSet rs = null;
GenVal genVal = new GenVal();
/* public void ejbCreate() throws RemoteException, CreateException /* public void ejbCreate() throws RemoteException, CreateException
{ {
...@@ -64,15 +64,15 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -64,15 +64,15 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException
{ {
String finalStr = ""; String finalStr = "";
Document dom = null; Document dom = null;
String userId="", errCode = "",resultString = ""; String userId="", errCode = "",resultString = "";
// finalStr = mergeXml(xmlString, xmlString1, xmlString2); // finalStr = mergeXml(xmlString, xmlString1, xmlString2);
try try
{ {
ConnDriver connDriver = new ConnDriver(); //***ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); //***conn = connDriver.getConnectDB("DriverITM");
connDriver = null; //**connDriver = null;
//System.out.println("xmlString2 : " + xmlString2); //System.out.println("xmlString2 : " + xmlString2);
dom = parseString(xmlString2); dom = parseString(xmlString2);
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
...@@ -80,11 +80,17 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -80,11 +80,17 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//for passing current focused Row from xtraParams //for passing current focused Row from xtraParams
String focusedRow = null; String focusedRow = null;
focusedRow = getValueFromXTRA_PARAMS(xtraParams, "focusRow"); focusedRow = getValueFromXTRA_PARAMS(xtraParams, "focusRow");
//System.out.println( "focusedRow :: " + focusedRow ); System.out.println( "winName :: " + winName );
System.out.println( "objContext :: " + objContext );
System.out.println( "focusedRow :: " + focusedRow );
System.out.println( "xmlString2 :: " + xmlString2 );
//errCode = genVal.genVal(winName,objContext,dom,conn); //errCode = genVal.genVal(winName,objContext,dom,conn);
errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn); //****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn);
GenVal genVal = new GenVal();
errCode = genVal.genVal(winName,objContext,dom, focusedRow);
genVal = null;
//changed by msalam on 27/09/07 end //changed by msalam on 27/09/07 end
if (errCode != null && errCode.trim().length() > 0) if (errCode != null && errCode.trim().length() > 0)
{ {
resultString = getErrorString("", errCode, userId); resultString = getErrorString("", errCode, userId);
} }
...@@ -99,7 +105,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -99,7 +105,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
{ {
e.printStackTrace(); e.printStackTrace();
} }
finally /*finally
{ {
try try
{ {
...@@ -111,7 +117,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -111,7 +117,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
catch(Exception ex) catch(Exception ex)
{ex.printStackTrace();} {ex.printStackTrace();}
} }*/
return resultString; return resultString;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment