Commit 92e55478 authored by prane's avatar prane

to lock and check the status again whether some other process is already being done simultaneously

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192241 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 730038d4
...@@ -16,6 +16,7 @@ import org.w3c.dom.Node; ...@@ -16,6 +16,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import ibase.system.config.AppConnectParm; import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
...@@ -395,7 +396,9 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal, ...@@ -395,7 +396,9 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal,
double exchRate=0.0; double exchRate=0.0;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null; PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null, rs1 = null, rs2 = null; ResultSet rs = null, rs1 = null, rs2 = null;
String sqlPdc= "", lsStatus="";
PreparedStatement pstmtPdc = null;
ResultSet rsPdc = null;
try try
{ {
...@@ -412,7 +415,21 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal, ...@@ -412,7 +415,21 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal,
parentNodeList = detailDom.getElementsByTagName("Detail2"); parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
System.out.println("ParentNodeListLength ..........."+parentNodeListLength); System.out.println("ParentNodeListLength ..........."+parentNodeListLength);
//Added By pavan R on 23oct18 [to lock and check the status again whether some other process is already being done simultaneously]
System.out.println("CommonConstants["+CommonConstants.DB_NAME+"]");
if ((CommonConstants.DB_NAME).equalsIgnoreCase("db2") || (CommonConstants.DB_NAME).equalsIgnoreCase("mysql"))
{
sqlPdc = "select status from pdc_received where tran_id = ? for update";
}
else if ((CommonConstants. DB_NAME).equalsIgnoreCase("mssql"))
{
sqlPdc = "select status from pdc_received (updlock) where tran_id = ? ";
}else
{
sqlPdc = "select status from pdc_received where tran_id = ? for update nowait";
}
pstmtPdc = conn.prepareStatement(sqlPdc);
//pavan R on 23oct18 -end
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++) for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{ {
parentNode = parentNodeList.item(selectedRow); parentNode = parentNodeList.item(selectedRow);
...@@ -426,6 +443,31 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal, ...@@ -426,6 +443,31 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal,
refDate=checkNull(genericUtility.getColumnValueFromNode("ref_date", parentNode)); refDate=checkNull(genericUtility.getColumnValueFromNode("ref_date", parentNode));
System.out.println("siteCode------>" + siteCode + " :" + TranIdPdc); System.out.println("siteCode------>" + siteCode + " :" + TranIdPdc);
System.out.println("refDate..........................**:"+refDate); System.out.println("refDate..........................**:"+refDate);
//Added By pavan R on 23oct18 [to lock and check the status again whether some other process is already being done simultaneously]
try
{
pstmtPdc.setString(1, TranIdPdc);
rsPdc = pstmtPdc.executeQuery();
if(rsPdc.next())
{
lsStatus = checkNull(rsPdc.getString("status"));
}
rsPdc.close();rsPdc = null;
if(!"C".equals(lsStatus))
{
errString = itmDBAccessEJB.getErrorString("","VTIVSTATPD","","",conn);
conn.rollback();
return errString;
}
}catch(Exception e)
{
errString = itmDBAccessEJB.getErrorString("","VTLCKERR","","",conn);
conn.rollback();
e.printStackTrace();
return errString;
}
pstmtPdc.clearParameters();
//pavan R on 23oct18 end
if(refDatePdc != null) if(refDatePdc != null)
...@@ -964,6 +1006,28 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal, ...@@ -964,6 +1006,28 @@ public class PdcToReceiptPrc extends ProcessEJB implements PdcToReceiptPrcLocal,
System.out.println("Closing Connection...."); System.out.println("Closing Connection....");
try try
{ {
//Added By pavan R on 23oct18 Start
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rsPdc != null)
{
rsPdc.close();
rsPdc = null;
}
if(pstmtPdc != null)
{
pstmtPdc.close();
pstmtPdc = null;
}
//pavan R on 23oct18 end
conn.close(); conn.close();
conn = null; conn = null;
} }
......
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