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

Replace UnallocatedMrketingDoc.java

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