Commit 5d4712a2 authored by dpawar's avatar dpawar

Manage Connection


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96123 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1e1817de
...@@ -29,9 +29,26 @@ import java.util.*; ...@@ -29,9 +29,26 @@ import java.util.*;
public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,MiscValConfRemote //SessionBean public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,MiscValConfRemote //SessionBean
{ {
public String confirm(String tranId,String xtraParams,String forcedFlag) throws RemoteException,ITMException public String confirm(String tranId,String xtraParams,String forcedFlag) throws RemoteException,ITMException{
{
String errString ="";
Connection conn = null; Connection conn = null;
try{
errString = confirm(tranId, xtraParams, forcedFlag, conn);
}catch (Exception e) {
// TODO: handle exception
System.out.println("Exception in confirm() ==>"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
System.out.println("errString in cofirm() ==>"+errString);
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String confirm(String tranId,String xtraParams,String forcedFlag,Connection conn) throws RemoteException,ITMException
{
//Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
...@@ -43,15 +60,22 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi ...@@ -43,15 +60,22 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi
FinCommon finCommon = null; FinCommon finCommon = null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
boolean isLocalConn = false;
if(conn==null){
isLocalConn = true;
}
try try
{ {
finCommon = new FinCommon(); finCommon = new FinCommon();
genericUtility = new GenericUtility(); genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
if(isLocalConn){
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
conn.setAutoCommit(false); conn.setAutoCommit(false);
}
sql =" select confirmed,site_code from MISC_VOUCHER where tran_id = ?"; sql =" select confirmed,site_code from MISC_VOUCHER where tran_id = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -97,11 +121,13 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi ...@@ -97,11 +121,13 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi
{ {
if(errString.indexOf("CONFSUCCES") > -1) if(errString.indexOf("CONFSUCCES") > -1)
{ {
conn.commit(); if(isLocalConn)
conn.commit();
} }
else else
{ {
conn.rollback(); if(isLocalConn)
conn.rollback();
} }
} }
if(rs != null) if(rs != null)
...@@ -114,7 +140,8 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi ...@@ -114,7 +140,8 @@ public class MiscValConf extends ActionHandlerEJB implements MiscValConfLocal,Mi
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); if(isLocalConn)
conn.close();
} }
catch(Exception e) catch(Exception e)
{ {
......
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