Commit 8a2f2991 authored by prane's avatar prane

closed rs and pstmt and added finally from the reference of E12ConnectionLog.jsp

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@197008 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3ca293b3
...@@ -161,7 +161,8 @@ public class MiscPayAct extends ActionHandlerEJB implements MiscPayActLocal,Misc ...@@ -161,7 +161,8 @@ public class MiscPayAct extends ActionHandlerEJB implements MiscPayActLocal,Misc
char sundryType1; char sundryType1;
int rowCnt = 0; int rowCnt = 0;
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null; //Pavan [closed expected opening cursor and pstmt].
PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ResultSet rs1 = null; ResultSet rs1 = null;
ResultSet rs2 = null; ResultSet rs2 = null;
...@@ -201,12 +202,15 @@ conn = getConnection(); ...@@ -201,12 +202,15 @@ conn = getConnection();
sql1="SELECT COUNT(*) AS ROWCNT FROM MISC_PAYABLES WHERE SITE_CODE = '"+ siteCode +"'" + " AND CURR_CODE = '"+currCode +"'" + " AND SUNDRY_TYPE = '"+ sundryType +"'"+"AND SUNDRY_CODE = '"+ sundryCode +"'"+" AND TOT_AMT - ADJ_AMT <> 0"; sql1="SELECT COUNT(*) AS ROWCNT FROM MISC_PAYABLES WHERE SITE_CODE = '"+ siteCode +"'" + " AND CURR_CODE = '"+currCode +"'" + " AND SUNDRY_TYPE = '"+ sundryType +"'"+"AND SUNDRY_CODE = '"+ sundryCode +"'"+" AND TOT_AMT - ADJ_AMT <> 0";
System.out.println("sql1 :="+sql1); System.out.println("sql1 :="+sql1);
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
rs = stmt.executeQuery(sql1); pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
rowCnt = rs.getInt("ROWCNT"); rowCnt = rs.getInt("ROWCNT");
} }
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
if (rowCnt == 0) if (rowCnt == 0)
{ {
errCode = "VTSTOCK1"; errCode = "VTSTOCK1";
...@@ -224,56 +228,80 @@ conn = getConnection(); ...@@ -224,56 +228,80 @@ conn = getConnection();
break; break;
case 'C': //Customer case 'C': //Customer
sql2 = "SELECT GROUP_CODE FROM CUSTOMER WHERE CUST_CODE = '"+ sundryCode +"'"; sql2 = "SELECT GROUP_CODE FROM CUSTOMER WHERE CUST_CODE = '"+ sundryCode +"'";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT CUST_CODE FROM CUSTOMER WHERE GROUP_CODE = '"+ grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT CUST_CODE FROM CUSTOMER WHERE GROUP_CODE = '"+ grpCode +"')";
break; break;
case 'R': //Strategic Customer case 'R': //Strategic Customer
sql2 = "SELECT GROUP_CODE FROM CUSTOMER WHERE CUST_CODE = (SELECT CUST_CODE FROM STRG_CUSTOMER WHERE SC_CODE = '"+ sundryCode +"')"; sql2 = "SELECT GROUP_CODE FROM CUSTOMER WHERE CUST_CODE = (SELECT CUST_CODE FROM STRG_CUSTOMER WHERE SC_CODE = '"+ sundryCode +"')";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null;
pstmt.close(); pstmt = null;
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT CUST_CODE FROM CUSTOMER WHERE GROUP_CODE = '" + grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT CUST_CODE FROM CUSTOMER WHERE GROUP_CODE = '" + grpCode +"')";
break; break;
case 'S': //Supplier case 'S': //Supplier
sql2 = " SELECT GROUP_CODE FROM SUPPLIER WHERE SUPP_CODE ='"+ sundryCode +"'"; sql2 = " SELECT GROUP_CODE FROM SUPPLIER WHERE SUPP_CODE ='"+ sundryCode +"'";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null;
pstmt.close(); pstmt = null;
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT SUPP_CODE FROM SUPPLIER WHERE GROUP_CODE ='"+ grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT SUPP_CODE FROM SUPPLIER WHERE GROUP_CODE ='"+ grpCode +"')";
break; break;
case 'B': //Bank case 'B': //Bank
sql2 = "SELECT GROUP_CODE FROM BANK WHERE BANK_CODE ='"+ sundryCode +"'"; sql2 = "SELECT GROUP_CODE FROM BANK WHERE BANK_CODE ='"+ sundryCode +"'";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null;
pstmt.close(); pstmt = null;
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT BANK_CODE FROM BANK WHERE GROUP_CODE ='"+ grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT BANK_CODE FROM BANK WHERE GROUP_CODE ='"+ grpCode +"')";
break; break;
case 'P': //Sales Person case 'P': //Sales Person
sql2 = "SELECT GROUP_CODE FROM SALES_PERS WHERE SALES_PERS ='"+ sundryCode +"'"; sql2 = "SELECT GROUP_CODE FROM SALES_PERS WHERE SALES_PERS ='"+ sundryCode +"'";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null;
pstmt.close(); pstmt = null;
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT SALES_PERS FROM SALES_PERS WHERE GROUP_CODE ='"+ grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT SALES_PERS FROM SALES_PERS WHERE GROUP_CODE ='"+ grpCode +"')";
break; break;
case 'T': //Transporter case 'T': //Transporter
sql2 = "SELECT GROUP_CODE FROM TRANSPORTER WHERE TRAN_CODE ='"+ sundryCode +"'"; sql2 = "SELECT GROUP_CODE FROM TRANSPORTER WHERE TRAN_CODE ='"+ sundryCode +"'";
rs1 = conn.createStatement().executeQuery(sql2); //rs1 = conn.createStatement().executeQuery(sql2); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql2);
rs1 = pstmt.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
grpCode = rs1.getString(1); grpCode = rs1.getString(1);
} }
rs1.close(); rs1 = null;
pstmt.close(); pstmt = null; //Pavan [closed expected opening cursor and pstmt].
str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT TRAN_CODE FROM TRANSPORTER WHERE GROUP_CODE ='"+ grpCode +"')"; str1 = "AND MISC_PAYABLES.SUNDRY_CODE IN (SELECT TRAN_CODE FROM TRANSPORTER WHERE GROUP_CODE ='"+ grpCode +"')";
break; break;
case 'X': //Tax Authority case 'X': //Tax Authority
...@@ -308,7 +336,9 @@ conn = getConnection(); ...@@ -308,7 +336,9 @@ conn = getConnection();
//sql4 = sql4 + " ORDER BY BILL_NO, BILL_DATE "; // changes by manazir on 29-06-09 R-ID FI89ALL069 //sql4 = sql4 + " ORDER BY BILL_NO, BILL_DATE "; // changes by manazir on 29-06-09 R-ID FI89ALL069
System.out.println("sql4:="+sql4); System.out.println("sql4:="+sql4);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
rs2 = conn.createStatement().executeQuery(sql4); //rs2 = conn.createStatement().executeQuery(sql4); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql4);
rs2 = pstmt.executeQuery();
while (rs2.next()) while (rs2.next())
{ {
double peindingQty = rs2.getDouble(8) - rs2.getDouble(9); double peindingQty = rs2.getDouble(8) - rs2.getDouble(9);
...@@ -345,7 +375,9 @@ conn = getConnection(); ...@@ -345,7 +375,9 @@ conn = getConnection();
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
//End //End
} }
stmt.close(); rs2.close(); rs2 = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
//stmt.close();
valueXmlString.append("</Root>\r\n"); valueXmlString.append("</Root>\r\n");
} }
catch(SQLException e) catch(SQLException e)
...@@ -361,7 +393,31 @@ conn = getConnection(); ...@@ -361,7 +393,31 @@ conn = getConnection();
finally finally
{ {
try{ try{
conn.close(); if(rs != null ) //Pavan [closed expected opening cursor and pstmt].
{
rs.close();
rs = null;
}
if(rs1 != null )
{
rs1.close();
rs1 = null;
}
if(rs2 != null )
{
rs2.close();
rs2 = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){} }catch(Exception e){}
} }
System.out.println("valueXmlString.toString() "+valueXmlString.toString()); System.out.println("valueXmlString.toString() "+valueXmlString.toString());
...@@ -376,7 +432,8 @@ conn = getConnection(); ...@@ -376,7 +432,8 @@ conn = getConnection();
String sql = ""; String sql = "";
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null; //Pavan [closed expected opening cursor and pstmt].
PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String errCode = "" ,errString = ""; String errCode = "" ,errString = "";
String detCnt = "0"; String detCnt = "0";
...@@ -396,16 +453,20 @@ conn = getConnection(); ...@@ -396,16 +453,20 @@ conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END //Changes and Commented By Bhushan on 06-06-2016 :END
tranId = genericUtility.getColumnValue("vouch_no",dom) + "%"; tranId = genericUtility.getColumnValue("vouch_no",dom) + "%";
System.out.println("actionAllRecords tranId ["+tranId + "]"); System.out.println("actionAllRecords tranId ["+tranId + "]");
sql = "SELECT REF_NO FROM MISC_PAYABLES WHERE REF_NO LIKE '"+ tranId +"'"+" AND CASE WHEN TOT_AMT IS NULL THEN 0 ELSE TOT_AMT END - CASE WHEN ADJ_AMT IS NULL THEN 0 ELSE ADJ_AMT END <> 0 AND CASE WHEN HOLD_AMT IS NULL THEN 0 ELSE HOLD_AMT END = 0"; sql = "SELECT REF_NO FROM MISC_PAYABLES WHERE REF_NO LIKE '"+ tranId +"'"+" AND CASE WHEN TOT_AMT IS NULL THEN 0 ELSE TOT_AMT END - CASE WHEN ADJ_AMT IS NULL THEN 0 ELSE ADJ_AMT END <> 0 AND CASE WHEN HOLD_AMT IS NULL THEN 0 ELSE HOLD_AMT END = 0"; //Pavan [closed expected opening cursor and pstmt].
stmt = conn.createStatement(); //stmt = conn.createStatement();
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
valueXmlString.append("<Detail>\r\n"); valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<vouch_no>").append("<![CDATA[").append( rs.getString(1) == null?"":rs.getString(1).trim() ).append("]]>").append("</vouch_no>\r\n"); valueXmlString.append("<vouch_no>").append("<![CDATA[").append( rs.getString(1) == null?"":rs.getString(1).trim() ).append("]]>").append("</vouch_no>\r\n");
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
} }
stmt.close(); //stmt.close();
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
valueXmlString.append("</Root>\r\n"); valueXmlString.append("</Root>\r\n");
} }
else else
...@@ -449,7 +510,8 @@ conn = getConnection(); ...@@ -449,7 +510,8 @@ conn = getConnection();
//System.out.println("\n voucherTransform is calling............."); //System.out.println("\n voucherTransform is calling.............");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null; //Pavan [closed expected opening cursor and pstmt].
PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Node currDetail = null; Node currDetail = null;
String sundryType = "", sundryCode = "", refNo = "", currCode = "", acctCode =""; String sundryType = "", sundryCode = "", refNo = "", currCode = "", acctCode ="";
...@@ -475,7 +537,7 @@ conn = getConnection(); ...@@ -475,7 +537,7 @@ conn = getConnection();
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END //Changes and Commented By Bhushan on 06-06-2016 :END
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
NodeList detailList = selDataDom.getElementsByTagName("Detail"); NodeList detailList = selDataDom.getElementsByTagName("Detail");
int noOfDetails = detailList.getLength(); int noOfDetails = detailList.getLength();
...@@ -496,11 +558,14 @@ conn = getConnection(); ...@@ -496,11 +558,14 @@ conn = getConnection();
+"TOT_AMT - ADJ_AMT, " +"TOT_AMT - ADJ_AMT, "
+"TRAN_SER " +"TRAN_SER "
+"FROM MISC_PAYABLES " +"FROM MISC_PAYABLES "
+"WHERE TRAN_ID = '"+tranId+"' "; +"WHERE TRAN_ID = ?" ; //'"+tranId+"' ";
System.out.println("sql :"+sql); System.out.println("sql :"+sql);
// PreparedStatement pstmt = conn.prepareStatement(sql); // PreparedStatement pstmt = conn.prepareStatement(sql); //Pavan [closed expected opening cursor and pstmt].
// pstmt.setString(1, tranId); // pstmt.setString(1, tranId);
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
sundryType = rs.getString(1); sundryType = rs.getString(1);
...@@ -515,6 +580,8 @@ conn = getConnection(); ...@@ -515,6 +580,8 @@ conn = getConnection();
payAmt = rs.getDouble(10); payAmt = rs.getDouble(10);
transSer = rs.getString(11); transSer = rs.getString(11);
} }
rs.close(); rs = null;
pstmt.close(); pstmt = null;
//System.out.println("sundryType :"+sundryType+" sundryCode :"+sundryCode+" refNo :"+refNo+" refDate :"+refDate+" currCode :"+currCode+" exchRate :"+exchRate+" acctCode :"+acctCode+" netAmt :"+netAmt+" payAmt :"+payAmt+" transSer :"+transSer); //System.out.println("sundryType :"+sundryType+" sundryCode :"+sundryCode+" refNo :"+refNo+" refDate :"+refDate+" currCode :"+currCode+" exchRate :"+exchRate+" acctCode :"+acctCode+" netAmt :"+netAmt+" payAmt :"+payAmt+" transSer :"+transSer);
hdrExchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom1)); hdrExchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom1));
tranIdHrd = genericUtility.getColumnValue("tran_id", dom1); tranIdHrd = genericUtility.getColumnValue("tran_id", dom1);
...@@ -616,12 +683,17 @@ conn = getConnection(); ...@@ -616,12 +683,17 @@ conn = getConnection();
taxClass = genericUtility.getColumnValue("tax_class", dom); taxClass = genericUtility.getColumnValue("tax_class", dom);
stationFr = genericUtility.getColumnValue("stan_code", dom); stationFr = genericUtility.getColumnValue("stan_code", dom);
sql = "SELECT STAN_CODE " sql = "SELECT STAN_CODE "
+"FROM SITE WHERE SITE_CODE = '"+siteCode+"' "; +"FROM SITE WHERE SITE_CODE = ?"; //'"+siteCode+"' "; //Pavan [closed expected opening cursor and pstmt].
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
stationTo = rs.getString(1); stationTo = rs.getString(1);
} }
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
//Commented and added below line by Varsha V on 05-02-19 to call getTaxEnv() method of DistCommon //Commented and added below line by Varsha V on 05-02-19 to call getTaxEnv() method of DistCommon
//taxEnv = itmDBAccessEJB.getTaxEnv(stationFr, stationTo, taxChap, taxClass, siteCode, conn); //taxEnv = itmDBAccessEJB.getTaxEnv(stationFr, stationTo, taxChap, taxClass, siteCode, conn);
taxEnv = disCommon.getTaxEnv(stationFr, stationTo, taxChap, taxClass, siteCode, conn); taxEnv = disCommon.getTaxEnv(stationFr, stationTo, taxChap, taxClass, siteCode, conn);
...@@ -666,6 +738,14 @@ conn = getConnection(); ...@@ -666,6 +738,14 @@ conn = getConnection();
{ {
try try
{ {
if(rs != null) //Pavan [closed expected opening cursor and pstmt].
{
rs.close(); rs = null;
}
if(pstmt != null)
{
pstmt.close(); pstmt = null;
}
System.out.println("Closing Connection....."); System.out.println("Closing Connection.....");
conn.close(); conn.close();
conn = null; conn = null;
...@@ -678,7 +758,8 @@ conn = getConnection(); ...@@ -678,7 +758,8 @@ conn = getConnection();
private String payableAt(String sundryType, String sundryCode, String bankCode)throws ITMException private String payableAt(String sundryType, String sundryCode, String bankCode)throws ITMException
{ {
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null; //Pavan [closed expected opening cursor and pstmt].
PreparedStatement pstmt = null;
String sql = "", payableAt = "", stanCode = "", bankRef = ""; String sql = "", payableAt = "", stanCode = "", bankRef = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
ResultSet rs = null; ResultSet rs = null;
...@@ -688,45 +769,54 @@ conn = getConnection(); ...@@ -688,45 +769,54 @@ conn = getConnection();
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END //Changes and Commented By Bhushan on 06-06-2016 :END
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
char sundryType1 = sundryType.charAt(0); char sundryType1 = sundryType.charAt(0);
switch (sundryType1) switch (sundryType1)
{ {
case 'E': case 'E':
sql = "SELECT DD_PAYABLE_BANK, STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = '"+sundryCode+"'"; sql = "SELECT DD_PAYABLE_BANK, STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = ?"; //'"+sundryCode+"'"; //Pavan [closed expected opening cursor and pstmt].
break; break;
case 'S': case 'S':
sql = "SELECT BANK_REF, STAN_CODE FROM SUPPLIER WHERE SUPP_CODE = '"+sundryCode+"'"; sql = "SELECT BANK_REF, STAN_CODE FROM SUPPLIER WHERE SUPP_CODE = ?"; //'"+sundryCode+"'";
break; break;
case 'C': case 'C':
sql = "SELECT BANK_NAME, STAN_CODE FROM CUSTOMER WHERE CUST_CODE = '"+sundryCode+"'"; sql = "SELECT BANK_NAME, STAN_CODE FROM CUSTOMER WHERE CUST_CODE = ?"; //'"+sundryCode+"'";
break; break;
case 'P': case 'P':
case 'T': case 'T':
sql = "SELECT PAYABLE_REF, STAN_CODE FROM TRANSPORTER WHERE TRAN_CODE = '"+sundryCode+"'"; sql = "SELECT PAYABLE_REF, STAN_CODE FROM TRANSPORTER WHERE TRAN_CODE = ?"; //'"+sundryCode+"'";
break; break;
case 'X': case 'X':
sql = "SELECT BANK_REF, STAN_CODE FROM TAX_AUTHORITY WHERE TAUTH_CODE = '"+sundryCode+"'"; sql = "SELECT BANK_REF, STAN_CODE FROM TAX_AUTHORITY WHERE TAUTH_CODE = ?"; //'"+sundryCode+"'";
}// switch end }// switch end
System.out.println("sql :"+sql); System.out.println("sql :"+sql);
if (sql != null) if (sql != null)
{ {
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql); //Pavan [closed expected opening cursor and pstmt].
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
payableAt = rs.getString(1); payableAt = rs.getString(1);
stanCode = rs.getString(2); stanCode = rs.getString(2);
} }
stmt.close(); //stmt.close();
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
} }
System.out.println("payableAt :"+payableAt); System.out.println("payableAt :"+payableAt);
if (payableAt == null || payableAt.trim().length() > 0) if (payableAt == null || payableAt.trim().length() > 0)
{ {
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
sql ="SELECT DRAWN_AT, BANK_REF FROM BANK_STAN_SERV WHERE BANK_CODE = '"+bankCode+"' " sql ="SELECT DRAWN_AT, BANK_REF FROM BANK_STAN_SERV WHERE BANK_CODE = ? " //'"+bankCode+"' "
+"AND STAN_CODE = '"+stanCode+"'"; +"AND STAN_CODE = ?"; //'"+stanCode+"'";
System.out.println("sql :"+sql); //System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
pstmt.setString(2, stanCode);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
payableAt = rs.getString(1); payableAt = rs.getString(1);
...@@ -734,6 +824,8 @@ conn = getConnection(); ...@@ -734,6 +824,8 @@ conn = getConnection();
bankRef = rs.getString(2); bankRef = rs.getString(2);
System.out.println("bankRef :"+bankRef); System.out.println("bankRef :"+bankRef);
} }
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
if (bankRef != null) if (bankRef != null)
{ {
payableAt = (payableAt == null?"":payableAt.trim()+", ")+bankRef.trim(); payableAt = (payableAt == null?"":payableAt.trim()+", ")+bankRef.trim();
...@@ -755,6 +847,14 @@ conn = getConnection(); ...@@ -755,6 +847,14 @@ conn = getConnection();
{ {
try try
{ {
if(rs != null) //Pavan [closed expected opening cursor and pstmt].
{
rs.close(); rs = null;
}
if(pstmt != null)
{
pstmt.close(); pstmt = null;
}
System.out.println("Closing Connection....."); System.out.println("Closing Connection.....");
conn.close(); conn.close();
conn = null; conn = null;
...@@ -767,58 +867,75 @@ conn = getConnection(); ...@@ -767,58 +867,75 @@ conn = getConnection();
private String stanDrawn(String sundryType, String sundryCode)throws ITMException private String stanDrawn(String sundryType, String sundryCode)throws ITMException
{ {
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null;
PreparedStatement pstmt = null, pstmt1 = null; //Pavan [closed expected opening cursor and pstmt].
String sql = "", empCode = "", stanCode = ""; String sql = "", empCode = "", stanCode = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
ResultSet rs = null; ResultSet rs = null, rs1 = null;
try try
{ {
//Changes and Commented By Bhushan on 06-06-2016 :START //Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END //Changes and Commented By Bhushan on 06-06-2016 :END
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
char sundryType1 = sundryType.charAt(0); char sundryType1 = sundryType.charAt(0);
switch (sundryType1) switch (sundryType1)
{ {
case 'E': case 'E':
sql = "SELECT STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = '"+sundryCode+"'"; sql = "SELECT STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = ?"; //'"+sundryCode+"'"; //Pavan [closed expected opening cursor and pstmt].
break; break;
case 'S': case 'S':
sql = "SELECT STAN_CODE FROM SUPPLIER WHERE SUPP_CODE = '"+sundryCode+"'"; sql = "SELECT STAN_CODE FROM SUPPLIER WHERE SUPP_CODE = ?"; //'"+sundryCode+"'"; //Pavan [closed expected opening cursor and pstmt].
break; break;
case 'C': case 'C':
sql = "SELECT STAN_CODE FROM CUSTOMER WHERE CUST_CODE = '"+sundryCode+"'"; sql = "SELECT STAN_CODE FROM CUSTOMER WHERE CUST_CODE = ?"; //'"+sundryCode+"'";
break; break;
case 'P': case 'P':
sql = "SELECT EMP_CODE FROM SALES_PERS WHERE SALES_PERS = '"+sundryCode+"'"; sql = "SELECT EMP_CODE FROM SALES_PERS WHERE SALES_PERS = ? "; //'"+sundryCode+"'";
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
if (rs.next()) pstmt1 = conn.prepareStatement(sql); //Pavan [closed expected opening cursor and pstmt].
pstmt1.setString(1, sundryCode);
rs1 = pstmt1.executeQuery();
rs1 = pstmt1.executeQuery();
if (rs1.next())
{ {
empCode = rs.getString(1); empCode = rs1.getString(1);
} }
rs1.close(); //Pavan [closed expected opening cursor and pstmt].
rs1 = null;
pstmt1.close();
pstmt1 = null;
if (empCode != null || empCode.trim().length() > 0) if (empCode != null || empCode.trim().length() > 0)
{ {
sql ="SELECT STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = '"+empCode+"'"; sql ="SELECT STAN_CODE FROM EMPLOYEE WHERE EMP_CODE = ?" ; //'"+empCode+"'"; //Pavan [closed expected opening cursor and pstmt].
sundryCode = empCode;
} }
stmt.close(); //stmt.close();
break; break;
case 'T': case 'T':
sql ="SELECT STAN_CODE FROM TRANSPORTER WHERE TRAN_CODE = '"+sundryCode+"'"; sql ="SELECT STAN_CODE FROM TRANSPORTER WHERE TRAN_CODE = ?"; //'"+sundryCode+"'"; //Pavan [closed expected opening cursor and pstmt].
break; break;
case 'X': case 'X':
sql ="SELECT STAN_CODE FROM TAX_AUTHORITY WHERE TAUTH_CODE = '"+sundryCode+"'"; sql ="SELECT STAN_CODE FROM TAX_AUTHORITY WHERE TAUTH_CODE = ?"; //'"+sundryCode+"'"; //Pavan [closed expected opening cursor and pstmt].
}// switch end }// switch end
System.out.println("sql :"+sql); //System.out.println("sql :"+sql);
if (sql != null) if (sql != null)
{ {
stmt = conn.createStatement(); //stmt = conn.createStatement(); //Pavan [closed expected opening cursor and pstmt].
rs = stmt.executeQuery(sql); //rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
stanCode = rs.getString(1); stanCode = rs.getString(1);
} }
stmt.close(); rs.close(); //Pavan [closed expected opening cursor and pstmt].
rs = null;
pstmt.close();
pstmt = null;
//stmt.close();
} }
System.out.println("stanCode :"+stanCode); System.out.println("stanCode :"+stanCode);
}// try end }// try end
...@@ -836,6 +953,22 @@ conn = getConnection(); ...@@ -836,6 +953,22 @@ conn = getConnection();
{ {
try try
{ {
if(rs != null) //Pavan [closed expected opening cursor and pstmt].
{
rs.close(); rs = null;
}
if(pstmt != null)
{
pstmt.close(); pstmt = null;
}
if(rs1 != null)
{
rs1.close(); rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close(); pstmt1 = null;
}
System.out.println("Closing Connection....."); System.out.println("Closing Connection.....");
conn.close(); conn.close();
conn = null; conn = null;
...@@ -849,7 +982,8 @@ conn = getConnection(); ...@@ -849,7 +982,8 @@ conn = getConnection();
{ {
System.out.println("bankCode :"+bankCode+" \n payMode :"+payMode+" \n tranDate :"+tranDate+" \n payAmt :"+payAmt); System.out.println("bankCode :"+bankCode+" \n payMode :"+payMode+" \n tranDate :"+tranDate+" \n payAmt :"+payAmt);
Connection conn = null; Connection conn = null;
Statement stmt = null; //Statement stmt = null; //Pavan [closed expected opening cursor and pstmt].
PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = "", cumulative = "", round = "", changeType = ""; String sql = "", cumulative = "", round = "", changeType = "";
double bankCharges = 0, roundTo = 0, minAmt = 0, maxAmt = 0, charges = 0; double bankCharges = 0, roundTo = 0, minAmt = 0, maxAmt = 0, charges = 0;
...@@ -879,7 +1013,7 @@ conn = getConnection(); ...@@ -879,7 +1013,7 @@ conn = getConnection();
+"AND MAX_AMT >= ? "; +"AND MAX_AMT >= ? ";
// java.sql.Date tranDate1 = java.sql.Date.valueOf(genericUtility.getValidDateString(tranDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())); // java.sql.Date tranDate1 = java.sql.Date.valueOf(genericUtility.getValidDateString(tranDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()));
// System.out.println("tranDate1 :"+tranDate1); // System.out.println("tranDate1 :"+tranDate1);
PreparedStatement pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql); //Pavan [closed expected opening cursor and pstmt].
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
pstmt.setString(2, payMode); pstmt.setString(2, payMode);
pstmt.setTimestamp(3, java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(tranDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); pstmt.setTimestamp(3, java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(tranDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
...@@ -896,6 +1030,8 @@ conn = getConnection(); ...@@ -896,6 +1030,8 @@ conn = getConnection();
roundTo = rs.getDouble(4); roundTo = rs.getDouble(4);
changeType = rs.getString(5); changeType = rs.getString(5);
} }
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
System.out.println("bankCharges :"+bankCharges+" cumulative :"+cumulative+" round :"+round+" roundTo:"+roundTo+" changeType :"+changeType); System.out.println("bankCharges :"+bankCharges+" cumulative :"+cumulative+" round :"+round+" roundTo:"+roundTo+" changeType :"+changeType);
if (changeType.equals("P")) if (changeType.equals("P"))
{ {
...@@ -951,11 +1087,15 @@ conn = getConnection(); ...@@ -951,11 +1087,15 @@ conn = getConnection();
} }
else else
{ {
rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
return 0; return 0;
} }
}//end if }//end if
}//end while }//end while
} rs.close(); rs = null; //Pavan [closed expected opening cursor and pstmt].
pstmt.close(); pstmt = null;
}
if (bankCharges == 0) if (bankCharges == 0)
{ {
return 0; return 0;
...@@ -980,6 +1120,14 @@ conn = getConnection(); ...@@ -980,6 +1120,14 @@ conn = getConnection();
{ {
try try
{ {
if(rs != null) //Pavan [closed expected opening cursor and pstmt].
{
rs.close(); rs = null;
}
if(pstmt != null)
{
pstmt.close(); pstmt = null;
}
System.out.println("Closing Connection....."); System.out.println("Closing Connection.....");
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