Commit edbb5168 authored by arawankar's avatar arawankar

FinCommon.java

-Locking implemented in fincommon ,as suggested by Manoharan sir.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194445 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d45aea93
...@@ -53,9 +53,20 @@ public class FinCommon ...@@ -53,9 +53,20 @@ public class FinCommon
double advAmount = 0.0; double advAmount = 0.0;
double crAmtBase = 0.0; double crAmtBase = 0.0;
double drAmtBase = 0.0; double drAmtBase = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString()); System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString())); java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
...@@ -207,6 +218,62 @@ public class FinCommon ...@@ -207,6 +218,62 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -339,6 +406,61 @@ public class FinCommon ...@@ -339,6 +406,61 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -436,9 +558,25 @@ public class FinCommon ...@@ -436,9 +558,25 @@ public class FinCommon
double lc_cramt_b = 0; double lc_cramt_b = 0;
double lc_dramt_b = 0; double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmDbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
System.out.println("Inside acctbalOpnUpd...."+acctbalMap.toString()); System.out.println("Inside acctbalOpnUpd...."+acctbalMap.toString());
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmDbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
stmt = conn.createStatement(); stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code"); String acctVar_contactcode = (String)acctbalMap.get("contact_code");
String acctVar_finentity = (String)acctbalMap.get("fin_entity"); String acctVar_finentity = (String)acctbalMap.get("fin_entity");
...@@ -563,6 +701,56 @@ public class FinCommon ...@@ -563,6 +701,56 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+ "WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+
...@@ -664,6 +852,57 @@ public class FinCommon ...@@ -664,6 +852,57 @@ public class FinCommon
} }
else else
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal // update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+ "WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+
...@@ -718,7 +957,7 @@ public class FinCommon ...@@ -718,7 +957,7 @@ public class FinCommon
try try
{ {
acctbalMap.clear(); acctbalMap.clear();
// ADDED BY ALKA // ADDED BY ALKA
if (rs != null) if (rs != null)
{ {
rs.close(); rs = null; rs.close(); rs = null;
...@@ -727,7 +966,7 @@ public class FinCommon ...@@ -727,7 +966,7 @@ public class FinCommon
{ {
pstmt.close(); pstmt = null; pstmt.close(); pstmt = null;
} }
// END ADDED BY ALKA // END ADDED BY ALKA
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -775,8 +1014,21 @@ public class FinCommon ...@@ -775,8 +1014,21 @@ public class FinCommon
double lc_cramt_b = 0.0; double lc_cramt_b = 0.0;
double lc_dramt_b = 0.0; double lc_dramt_b = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString()); System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString())); java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
...@@ -1042,6 +1294,54 @@ public class FinCommon ...@@ -1042,6 +1294,54 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -1173,8 +1473,57 @@ public class FinCommon ...@@ -1173,8 +1473,57 @@ public class FinCommon
}//if }//if
else else
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_closeprd);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -1288,8 +1637,22 @@ public class FinCommon ...@@ -1288,8 +1637,22 @@ public class FinCommon
double lc_cramt_b = 0; double lc_cramt_b = 0;
double lc_dramt_b = 0; double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmdbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmdbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("Inside acctbalMap......"+acctbalMap.toString()); System.out.println("Inside acctbalMap......"+acctbalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code"); String acctVar_contactcode = (String)acctbalMap.get("contact_code");
...@@ -1506,8 +1869,59 @@ public class FinCommon ...@@ -1506,8 +1869,59 @@ public class FinCommon
} }
else else
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_prdcode+"' AND "+ "WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_prdcode+"' AND "+
...@@ -1617,6 +2031,56 @@ public class FinCommon ...@@ -1617,6 +2031,56 @@ public class FinCommon
else else
{ {
try{ //poonam try{ //poonam
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_closeprd);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal // update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+ "WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+
...@@ -2065,7 +2529,7 @@ public class FinCommon ...@@ -2065,7 +2529,7 @@ public class FinCommon
{ {
lc_exch_rate = rs1.getDouble(1); lc_exch_rate = rs1.getDouble(1);
} }
// stmt.close(); stmt = null; // stmt.close(); stmt = null;
rs1.close(); rs1 = null; rs1.close(); rs1 = null;
} }
else else
......
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