Commit d881df09 authored by prane's avatar prane

changed stmt to pstmt, added finally block and chnages in sql in getConvQuantityFact

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195726 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ff76b7f0
...@@ -23,6 +23,7 @@ import ibase.utility.CommonConstants; ...@@ -23,6 +23,7 @@ import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.fin.FinCommon; import ibase.webitm.ejb.fin.FinCommon;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import ibase.webitm.ejb.sys.UtilMethods; import ibase.webitm.ejb.sys.UtilMethods;
...@@ -5461,7 +5462,8 @@ public class DistCommon { ...@@ -5461,7 +5462,8 @@ public class DistCommon {
ArrayList returnValue = new ArrayList(); ArrayList returnValue = new ArrayList();
String errCode = ""; String errCode = "";
String sql = ""; String sql = "";
Statement stmt; //Statement stmt;//[changed to prepared Statement by Pavan R]
PreparedStatement pstmt = null;
ResultSet conRs = null; ResultSet conRs = null;
if (frUom.trim().equals(toUom.trim())) { if (frUom.trim().equals(toUom.trim())) {
fact = 1; fact = 1;
...@@ -5471,40 +5473,58 @@ public class DistCommon { ...@@ -5471,40 +5473,58 @@ public class DistCommon {
} }
try { try {
stmt = connectionObject.createStatement(); //[stmt changed to pstmt and commented common sql Pavan R]
//stmt = connectionObject.createStatement();
// Check for unit in actual order with item code // Check for unit in actual order with item code
sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='" sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR= ?"
+ frUom.trim() + "' AND UNIT__TO='" + toUom.trim() //+ frUom.trim() + "' AND UNIT__TO='" + toUom.trim()
+ "' AND ITEM_CODE='" + forItem.trim() + "'"; //+ "' AND ITEM_CODE='" + forItem.trim() + "'";
conRs = stmt.executeQuery(sql); + " AND UNIT__TO = ? "
+ "' AND ITEM_CODE = ?";
//conRs = stmt.executeQuery(sql);
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, frUom.trim());
pstmt.setString(2, toUom.trim());
pstmt.setString(3, forItem.trim());
conRs = pstmt.executeQuery();
if (conRs.next()) { if (conRs.next()) {
mConv = conRs.getDouble(1); mConv = conRs.getDouble(1);
mRound = conRs.getString(2); mRound = conRs.getString(2);
mRndTo = conRs.getDouble(3); mRndTo = conRs.getDouble(3);
lsOrder = "ACTORD"; lsOrder = "ACTORD";
} else { } else {
sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='" /*sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='"//[commented by Pavan R]
+ toUom.trim() + toUom.trim()
+ "' AND UNIT__TO='" + "' AND UNIT__TO='"
+ frUom.trim() + frUom.trim()
+ "' AND ITEM_CODE='" + forItem.trim() + "'"; + "' AND ITEM_CODE='" + forItem.trim() + "'";*/
pstmt.clearParameters();
conRs.close(); conRs.close();
conRs = null; conRs = null;
conRs = stmt.executeQuery(sql); //conRs = stmt.executeQuery(sql);
pstmt.setString(1, toUom.trim());
pstmt.setString(2, frUom.trim());
pstmt.setString(3, forItem.trim());
conRs = pstmt.executeQuery();
if (conRs.next()) { if (conRs.next()) {
mConv = conRs.getDouble(1); mConv = conRs.getDouble(1);
mRound = conRs.getString(2); mRound = conRs.getString(2);
mRndTo = conRs.getDouble(3); mRndTo = conRs.getDouble(3);
lsOrder = "REVORD"; lsOrder = "REVORD";
} else { } else {
pstmt.clearParameters();
conRs.close(); conRs.close();
conRs = null; conRs = null;
sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='" /*sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='"//[commented by Pavan R]
+ frUom.trim() + frUom.trim()
+ "' AND UNIT__TO='" + "' AND UNIT__TO='"
+ toUom.trim() + toUom.trim()
+ "' AND ITEM_CODE='X'"; + "' AND ITEM_CODE='X'";*/
conRs = stmt.executeQuery(sql); //conRs = stmt.executeQuery(sql);
pstmt.setString(1, frUom.trim());
pstmt.setString(2, toUom.trim());
pstmt.setString(3, "X");
conRs = pstmt.executeQuery();
if (conRs.next()) { if (conRs.next()) {
mConv = conRs.getDouble(1); mConv = conRs.getDouble(1);
mRound = conRs.getString(2); mRound = conRs.getString(2);
...@@ -5513,13 +5533,19 @@ public class DistCommon { ...@@ -5513,13 +5533,19 @@ public class DistCommon {
} }
else { else {
pstmt.clearParameters();
conRs.close(); conRs.close();
conRs = null; conRs = null;
sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='" /*sql = "SELECT FACT, ROUND, ROUND_TO FROM UOMCONV WHERE UNIT__FR='"//[commented by Pavan R]
+ toUom.trim() + toUom.trim()
+ "' AND UNIT__TO='" + "' AND UNIT__TO='"
+ frUom.trim() + "' AND ITEM_CODE='X'"; + frUom.trim() + "' AND ITEM_CODE='X'";*/
conRs = stmt.executeQuery(sql); //conRs = stmt.executeQuery(sql);
pstmt.setString(1, toUom.trim());
pstmt.setString(2, frUom.trim());
pstmt.setString(3, "X");
conRs = pstmt.executeQuery();
if (conRs.next()) { if (conRs.next()) {
mConv = conRs.getDouble(1); mConv = conRs.getDouble(1);
mRound = conRs.getString(2); mRound = conRs.getString(2);
...@@ -5529,6 +5555,10 @@ public class DistCommon { ...@@ -5529,6 +5555,10 @@ public class DistCommon {
} else { } else {
returnValue.add(Double.toString(fact)); returnValue.add(Double.toString(fact));
returnValue.add(Double.toString(errQty)); returnValue.add(Double.toString(errQty));
conRs.close();//[closed and nulled conRs and pstmt by Pavan R]
conRs = null;
pstmt.close();
pstmt = null;
return returnValue; return returnValue;
} }
} }
...@@ -5536,8 +5566,10 @@ public class DistCommon { ...@@ -5536,8 +5566,10 @@ public class DistCommon {
} }
conRs.close(); conRs.close();
conRs = null; conRs = null;
stmt.close(); //stmt.close();
stmt = null; //stmt = null;
pstmt.close();
pstmt = null;
// Check whether conversion factor need to be assigned // Check whether conversion factor need to be assigned
if (fact == 0) { if (fact == 0) {
if (lsOrder.equals("ACTORD")) { if (lsOrder.equals("ACTORD")) {
...@@ -5560,6 +5592,22 @@ public class DistCommon { ...@@ -5560,6 +5592,22 @@ public class DistCommon {
System.out.println("Exception :ITMDBAccessEJB :Conversion:" System.out.println("Exception :ITMDBAccessEJB :Conversion:"
+ e.getMessage() + ":"); + e.getMessage() + ":");
}finally
{
try
{
if (conRs != null)
{
conRs.close();
conRs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
} }
return returnValue; return returnValue;
} }
......
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