Commit 0628cdfd authored by Ketan Patil's avatar Ketan Patil

Replace UnallocatedMrketingDoc.java

parent 4dd449ad
......@@ -9,6 +9,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
......@@ -25,11 +26,10 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
String strGetObj = "select obj_name from unallocated_attach WHERE STATUS='N' AND upper(obj_name) = 'MARKETING_BILL' group by obj_name";
String objName = "";
Connection conn = null;
PreparedStatement pstmtParamName=null;
PreparedStatement pstmtParamName2=null;
ResultSet rsCnt2=null;
ResultSet rsCnt =null;
PreparedStatement pstmtParamName=null;
ResultSet rsCnt2 =null;
ResultSet rsCnt=null;
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
......@@ -59,13 +59,10 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
pstmtParamName = null;
rsCnt.close();
rsCnt = null;
//added by sangita 21-4-23
pstmtParamName2.close();
pstmtParamName2 = null;
rsCnt2.close();
rsCnt2 = null;
//added by sangita 21-4-23
if (docIds != null && !docIds.isEmpty()) {
unallocDocIds = "";
......@@ -100,36 +97,13 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
var25.printStackTrace();
} finally {
try {
if (conn != null) {
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
closePreparedStatement(pstmtParamName2);
closeResultSet(rsCnt2);
if(rsCnt2 !=null)
{
rsCnt2.close();
rsCnt2 = null;
}
if(rsCnt !=null)
{
rsCnt.close();
rsCnt = null;
}
if(pstmtParamName !=null)
{
pstmtParamName.close();
pstmtParamName = null;
}
if(pstmtParamName2 !=null)
{
pstmtParamName2.close();
pstmtParamName2 = null;
}
conn.close();
}
......@@ -206,13 +180,17 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
String objName = "";
Connection conn = null;
HashMap newUnAllocDocMap = new HashMap();
PreparedStatement pstmtParamName=null;
PreparedStatement pstmtParamName2=null;
ResultSet rsCnt =null;
ResultSet rsCnt2=null;
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
PreparedStatement pstmtParamName = conn.prepareStatement(
pstmtParamName = conn.prepareStatement(
"select obj_name from unallocated_attach WHERE STATUS='N' AND upper(obj_name) = 'MARKETING_BILL' group by obj_name");
ResultSet rsCnt = pstmtParamName.executeQuery();
rsCnt = pstmtParamName.executeQuery();
ArrayList docIds;
while (rsCnt.next()) {
......@@ -231,7 +209,7 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
strGetDocId = "select doc_id from UNALLOCATED_ATTACH where STATUS='N' and OBJ_NAME = ? order by Added_on ,ref_id";
}
PreparedStatement pstmtParamName2 = conn.prepareStatement(strGetDocId);
pstmtParamName2 = conn.prepareStatement(strGetDocId);
pstmtParamName2.setString(1, rsCnt.getString(1));
if (endTime != null && endTime.trim().length() > 0) {
if (inProcessDocIds != null && inProcessDocIds.trim().length() > 0) {
......@@ -244,16 +222,19 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
pstmtParamName2.setString(2, inProcessDocIds);
}
ResultSet rsCnt2 = pstmtParamName2.executeQuery();
rsCnt2 = pstmtParamName2.executeQuery();
docIds = new ArrayList();
while (rsCnt2.next()) {
docIds.add(rsCnt2.getString(1));
}
closePreparedStatement(pstmtParamName2);
closeResultSet(rsCnt2);
this.mapList.put(objName, docIds);
newUnAllocDocMap.put(objName, docIds);
}
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
System.out.println(
"\n====================================== In appendDocument() ==========================================\n");
......@@ -272,6 +253,13 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
} finally {
try {
if (conn != null) {
closePreparedStatement(pstmtParamName2);
closeResultSet(rsCnt2);
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
conn.close();
}
......@@ -298,18 +286,22 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
public String getDocumentTime() {
Connection conn = null;
String maxTime = "";
ResultSet rsCnt=null;
PreparedStatement pstmtParamName =null;
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
String sql = "SELECT to_char(MAX(added_on), 'dd/MM/yy HH24:MI:SS') FROM UNALLOCATED_ATTACH where STATUS='N'";
PreparedStatement pstmtParamName = conn.prepareStatement(
pstmtParamName = conn.prepareStatement(
"SELECT to_char(MAX(added_on), 'dd/MM/yy HH24:MI:SS') FROM UNALLOCATED_ATTACH where STATUS='N'");
for (ResultSet rsCnt = pstmtParamName.executeQuery(); rsCnt.next(); maxTime = rsCnt.getString(1)) {
for ( rsCnt = pstmtParamName.executeQuery();
rsCnt.next();
maxTime = rsCnt.getString(1)) {
;
}
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
System.out.println("maxTime = [" + maxTime + "]");
} catch (SQLException var19) {
var19.printStackTrace();
......@@ -318,6 +310,8 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
} finally {
try {
if (conn != null) {
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
conn.close();
}
......@@ -330,6 +324,8 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
try {
if (conn != null) {
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
conn.close();
}
......@@ -406,6 +402,8 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
} finally {
try {
if (localConn && conn != null) {
closePreparedStatement(pstmt);
conn.close();
conn = null;
}
......@@ -417,6 +415,7 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
try {
if (localConn && conn != null) {
conn.close();
conn = null;
}
......@@ -442,6 +441,10 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
if (rs.next()) {
refSer = rs.getString("REF_SER") == null ? "" : rs.getString("REF_SER");
}
pStmt.close();
pStmt = null;
rs.close();
rs = null;
} catch (Exception var17) {
System.out.println("[UnallocatedMrketingDoc] :: [getRefSer()] :: " + var17.getMessage());
throw new ITMException(var17);
......@@ -496,6 +499,10 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
if (rs.next()) {
refId = rs.getString("REF_ID") == null ? "" : rs.getString("REF_ID");
}
pStmt.close();
pStmt = null;
rs.close();
rs = null;
} catch (Exception var18) {
System.out.println("[UnallocatedMrketingDoc] :: [getRefId()] :: " + var18.getMessage());
throw new ITMException(var18);
......@@ -541,15 +548,19 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
String objName = "";
Connection conn = null;
HashMap newUnAllocDocMap = new HashMap();
PreparedStatement pstmtParamName=null;
PreparedStatement pstmtParamName2=null;
ResultSet rsCnt2=null;
ResultSet rsCnt=null;
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
String strGetObj = "select obj_name from unallocated_attach WHERE STATUS='N' AND upper(obj_name) = 'MARKETING_BILL' group by obj_name";
ArrayList docIds = new ArrayList();
PreparedStatement pstmtParamName = conn.prepareStatement(
pstmtParamName = conn.prepareStatement(
"select obj_name from unallocated_attach WHERE STATUS='N' AND upper(obj_name) = 'MARKETING_BILL' group by obj_name");
ResultSet rsCnt = pstmtParamName.executeQuery();
rsCnt = pstmtParamName.executeQuery();
String unallocDocIds;
while (rsCnt.next()) {
......@@ -557,14 +568,17 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
System.out.println("objName = [" + objName + "]");
unallocDocIds = "";
unallocDocIds = "SELECT DOC_ID FROM UNALLOCATED_ATTACH WHERE STATUS='N' AND OBJ_NAME = ? AND ADDED_TO_MAP != 1 ORDER BY ADDED_ON, REF_ID";
PreparedStatement pstmtParamName2 = conn.prepareStatement(unallocDocIds);
pstmtParamName2 = conn.prepareStatement(unallocDocIds);
pstmtParamName2.setString(1, objName);
ResultSet rsCnt2 = pstmtParamName2.executeQuery();
rsCnt2 = pstmtParamName2.executeQuery();
while (rsCnt2.next()) {
docIds.add(rsCnt2.getString(1));
}
pstmtParamName2.close();
pstmtParamName = null;
rsCnt2.close();
rsCnt2 = null;
newUnAllocDocMap.put(objName, docIds);
}
......@@ -596,6 +610,10 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
} finally {
try {
if (conn != null) {
closePreparedStatement(pstmtParamName);
closeResultSet(rsCnt);
closePreparedStatement(pstmtParamName2);
closeResultSet(rsCnt2);
conn.close();
}
......@@ -650,6 +668,7 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
try {
if (conn != null) {
closePreparedStatement(pstmt);
conn.close();
conn = null;
}
......@@ -659,6 +678,8 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
} finally {
try {
if (conn != null) {
closePreparedStatement(pstmt);
conn.close();
conn = null;
}
......@@ -679,4 +700,68 @@ public class UnallocatedMrketingDoc implements UnallocatedMrketingDocRemote, Una
return updateCnt;
}
private void closePreparedStatement(PreparedStatement pstmt)
{
if(pstmt != null)
{
try
{
if(!pstmt.isClosed())
{
pstmt.close();
}
} catch (SQLException e)
{
System.out.println("PreparedStatement::>> Exception is ["+e.getMessage()+"]");
e.printStackTrace();
}
finally
{
pstmt = null;
}
}
}
private void closeStatement(Statement stmt)
{
if(stmt != null)
{
try
{
if(!stmt.isClosed())
{
stmt.close();
}
} catch (SQLException e)
{
System.out.println("Statement::>> Exception is ["+e.getMessage()+"]");
e.printStackTrace();
}
finally
{
stmt = null;
}
}
}
private void closeResultSet(ResultSet rs)
{
if(rs != null)
{
try
{
if(!rs.isClosed())
{
rs.close();
}
} catch (SQLException e)
{
System.out.println("ResultSet::>> Exception is ["+e.getMessage()+"]");
e.printStackTrace();
}
finally
{
rs = null;
}
}
}
}
\ No newline at end of file
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