Commit 65066dc8 authored by ssalve's avatar ssalve

Sarita: Done changes to close connection and prepare statement , resultset and...

Sarita: Done changes to close connection and prepare statement , resultset and rollback connection if error occures on 29 JUN 18

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187081 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6c989594
......@@ -666,7 +666,19 @@ conn = getConnection();
siteCode = rs1.getString(4) == null ? "":rs1.getString(4);
procDate2ts = rs1.getTimestamp(5); // Format procDate2ts :2012-06-01 00:00:00.0
}
pstmt1.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt1.clearParameters();
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
procDate2d = sdf.format(procDate2ts); // procDate2d : [01/06/12]
......@@ -683,7 +695,20 @@ conn = getConnection();
{
prdCdUpto = rs2.getString(1) == null ? "":rs2.getString(1);
}
pstmt2.clearParameters(); System.out.println(">>>>PERIOD CODE UP TO>>>"+prdCdUpto);
//done changes to close resultset and prepaestatement on 29JUN18
// pstmt2.clearParameters();
if (rs2 != null)
{
rs2.close();
rs2 = null;
}
if (pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
System.out.println(">>>>PERIOD CODE UP TO>>>"+prdCdUpto);
if(prdCdUpto == "" || prdCdUpto.trim().length() == 0 )
{
......@@ -698,7 +723,18 @@ conn = getConnection();
{
prdCdUpto = rs3.getString(1) == null ? "":rs3.getString(1);
}
pstmt3.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt3.clearParameters();
if (rs3 != null)
{
rs3.close();
rs3 = null;
}
if (pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
//changes by sarita on 06 JUN 2018 to set current date Timestamp parameter
//sql = "select code from period where fr_date = (select fr_date from period where code = (select acct_prd from period where '"+currAppdate+"' between fr_date and to_date))";
......@@ -711,7 +747,18 @@ conn = getConnection();
{
prdCdUpfr = rs4.getString(1) == null ? "":rs4.getString(1);
}
pstmt4.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
///pstmt4.clearParameters();
if (rs4 != null)
{
rs4.close();
rs4 = null;
}
if (pstmt4 != null)
{
pstmt4.close();
pstmt4 = null;
}
System.out.println("prdCdUpfr.compareTo(prdCdUpto) > 0 >>> prdCdUpfr "+prdCdUpfr+">>>>>prdCdUpto"+prdCdUpto);
if(prdCdUpfr.compareTo(prdCdUpto) > 0)
......@@ -731,7 +778,19 @@ conn = getConnection();
{
saleCd = rs5.getString(1) == null ? "":rs5.getString(1);
}
pstmt5.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt5.clearParameters();
if (rs5 != null)
{
rs5.close();
rs5 = null;
}
if (pstmt5 != null)
{
pstmt5.close();
pstmt5 = null;
}
System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto);
......@@ -749,7 +808,19 @@ conn = getConnection();
remValues = rs6.getDouble("rem_value");
}
System.out.println("Origional Values of asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
pstmt6.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt6.clearParameters();
if (rs6 != null)
{
rs6.close();
rs6 = null;
}
if (pstmt6 != null)
{
pstmt6.close();
pstmt6 = null;
}
//Added by sarita on 19 JUN 18 to store asset_register values before update [END]
if(saleCd.compareTo(prdCdUpto) >= 0)
......@@ -769,7 +840,13 @@ conn = getConnection();
{
System.out.println("Records Updated");
}
pstmt7.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt7.clearParameters();
if (pstmt7 != null)
{
pstmt7.close();
pstmt7 = null;
}
}//end of if for (saleCd.compareTo(prdCdUpto) >= 0)
......@@ -860,12 +937,18 @@ conn = getConnection();
pstmt8.setDouble(5, remValues);
pstmt8.setString(6, assetCode);
int chkData = pstmt8.executeUpdate();
conn.commit(); // done changes to commit transaction on 29 JUN 18 SARITA [START]
if(chkData > 0)
{
System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
}
pstmt8.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
// pstmt8.clearParameters();
if (pstmt8 != null)
{
pstmt8.close();
pstmt8 = null;
}
//Added by sarita to update original values if error occurred on retString on 19 JUN 18 [END]
errString = itmdbAccess.getErrorString("", errCode, "", "", conn); System.out.println("errString :>>kkk"+errString);
return errString;
......@@ -888,7 +971,18 @@ conn = getConnection();
grpCode = rs9.getString(7) == null ? "":rs9.getString(7);
depramtrevl = rs9.getDouble(8);
}
pstmt9.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
// pstmt9.clearParameters();
if (rs9 != null)
{
rs9.close();
rs9 = null;
}
if (pstmt9 != null)
{
pstmt9.close();
pstmt9 = null;
}
sql10 = "select sum(case when revalue_amt is null then 0 else revalue_amt end) from asset_revalue where asset_code = ? and confirmed = ?";
pstmt10=conn.prepareStatement(sql10);
......@@ -899,7 +993,18 @@ conn = getConnection();
{
revalamt = rs10.getDouble(1);
}
pstmt10.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt10.clearParameters();
if (rs10 != null)
{
rs10.close();
rs10 = null;
}
if (pstmt10 != null)
{
pstmt10.close();
pstmt10 = null;
}
// Total Cost is Total Value + Ravalued Amount
......@@ -939,7 +1044,18 @@ conn = getConnection();
{
varVal = rs11.getString(1) == null ? "":rs11.getString(1);
}
pstmt11.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt11.clearParameters();
if (rs11 != null)
{
rs11.close();
rs11 = null;
}
if (pstmt11 != null)
{
pstmt11.close();
pstmt11 = null;
}
if(varVal == null || varVal.equals("N"))
{
......@@ -951,7 +1067,18 @@ conn = getConnection();
{
modVat = rs12.getDouble(1);
}
pstmt12.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt12.clearParameters();
if (rs12 != null)
{
rs12.close();
rs12 = null;
}
if (pstmt12 != null)
{
pstmt12.close();
pstmt12 = null;
}
}
proLoss = (saleAmt + depramt + depramtrevl) - (totval + modVat + taxAmt);
......@@ -1020,7 +1147,13 @@ conn = getConnection();
pstmt13.setDouble(1, proLoss);
pstmt13.setString(2, assetCode);
pstmt13.executeUpdate();
pstmt13.clearParameters();
//done changes to close resultset and prepaestatement on 29JUN18
//pstmt13.clearParameters();
if (pstmt13 != null)
{
pstmt13.close();
pstmt13 = null;
}
}//end of if for confirmed
// Commented and added if statement to give naming to rs and pstmt and close them after while statement by sarita on 26 JUN 18 [END]
else
......@@ -1030,96 +1163,6 @@ conn = getConnection();
return errString;
}
}//end of while statement
//Added by sarita on 26 JUN 18 to close resultset and preparestatement [START]
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
if (rs2 != null) {
rs2.close();
rs2 = null;
}
if (pstmt2 != null) {
pstmt2.close();
pstmt2 = null;
}
if (rs3 != null) {
rs3.close();
rs3 = null;
}
if (pstmt3 != null) {
pstmt3.close();
pstmt3 = null;
}
if (rs4 != null) {
rs4.close();
rs4 = null;
}
if (pstmt4 != null) {
pstmt4.close();
pstmt4 = null;
}
if (rs5 != null) {
rs5.close();
rs5 = null;
}
if (pstmt5 != null) {
pstmt5.close();
pstmt5 = null;
}
if (rs6 != null) {
rs6.close();
rs6 = null;
}
if (pstmt6 != null) {
pstmt6.close();
pstmt6 = null;
}
if (pstmt7 != null) {
pstmt7.close();
pstmt7 = null;
}
if (rs9 != null) {
rs9.close();
rs9 = null;
}
if (pstmt9 != null) {
pstmt9.close();
pstmt9 = null;
}
if (rs10 != null) {
rs10.close();
rs10 = null;
}
if (pstmt10 != null) {
pstmt10.close();
pstmt10 = null;
}
if (rs11 != null) {
rs11.close();
rs11 = null;
}
if (pstmt11 != null) {
pstmt11.close();
pstmt11 = null;
}
if (rs12 != null) {
rs12.close();
rs12 = null;
}
if (pstmt12 != null) {
pstmt12.close();
pstmt12 = null;
}
if (pstmt13 != null) {
pstmt13.close();
pstmt13 = null;
}
//Added by sarita on 26 JUN 18 to close resultset and preparestatement [END]
//Commented by sarita on 26 JUN 18 to use if condition to close rs and pstmt[START]
if(rs != null)
{
......@@ -1199,15 +1242,50 @@ conn = getConnection();
//Added and Commented by sarita on 26 JUN 18 [START]
}//end of try block
catch(Exception e)
{
//done changes to rollback connection if exception occures on 29 JUN 18 SARITA[start]
System.out.println("AssetSalesConf:confirm..."+e.getMessage());
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
e.printStackTrace();
System.out.println("Exception AssetSalesConf:confirm "
+ e.getMessage());
errString = e.getMessage();
throw new ITMException(e);
}
//done changes to rollback connection if exception occures on 29 JUN 18 SARITA[end]
/*e.printStackTrace();
System.out.println("Exception AssetSalesConf:confirm "
+ e.getMessage());
errString = e.getMessage();
throw new ITMException(e);*/
} finally {
} finally
{
try {
//changes to check errString on 29 JUN 18 [START]
if (errString != null && errString.trim().length() > 0)
{
System.out.println("--going to commit tranaction--");
if (errString.indexOf("VTCNFSUCC") > -1)
{
conn.commit();
System.out.println("--transaction commited--");
}
else
{
conn.rollback();
System.out.println("--transaction rollback--");
}
}
//changes to check errString on 29 JUN 18 [END]
if (rs != null) {
rs.close();
rs = null;
......@@ -1310,11 +1388,13 @@ conn = getConnection();
pstmt13 = null;
}
//Added by sarita to close resultset and preparestatement on 26 JUN 18 [START]
if (conn != null) {
if (conn != null)
{
conn.close();
}
conn = null;
} catch (Exception d) {
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception AssetSalesConf:confirm " + d);
}
......
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