* db connection fix
This commit is contained in:
parent
a4ca3e8948
commit
9a1d6791dd
|
@ -21,7 +21,6 @@ import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import javax.sql.RowSet;
|
import javax.sql.RowSet;
|
||||||
import javax.swing.JComponent;
|
|
||||||
|
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
@ -177,24 +176,28 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
+ " AND (f.IsEncrypted='Y' OR f.ObscureType IS NOT NULL))"
|
+ " AND (f.IsEncrypted='Y' OR f.ObscureType IS NOT NULL))"
|
||||||
+ "ORDER BY SeqNo";
|
+ "ORDER BY SeqNo";
|
||||||
MRole role = MRole.getDefault(getCtx(), false);
|
MRole role = MRole.getDefault(getCtx(), false);
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
pstmt.setInt(1, get_ID());
|
pstmt.setInt(1, get_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
MPrintFormatItem pfi = new MPrintFormatItem(p_ctx, rs, get_TrxName());
|
MPrintFormatItem pfi = new MPrintFormatItem(p_ctx, rs, get_TrxName());
|
||||||
if (role.isColumnAccess(getAD_Table_ID(), pfi.getAD_Column_ID(), true))
|
if (role.isColumnAccess(getAD_Table_ID(), pfi.getAD_Column_ID(), true))
|
||||||
list.add (pfi);
|
list.add (pfi);
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
MPrintFormatItem[] retValue = new MPrintFormatItem[list.size()];
|
MPrintFormatItem[] retValue = new MPrintFormatItem[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
|
@ -422,12 +425,14 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
+ "WHERE t.AD_Table_ID=? AND c.AD_Client_ID=?" // #1/2
|
+ "WHERE t.AD_Table_ID=? AND c.AD_Client_ID=?" // #1/2
|
||||||
+ " AND pc.IsDefault='Y' AND pf.IsDefault='Y' AND pp.IsDefault='Y'";
|
+ " AND pc.IsDefault='Y' AND pf.IsDefault='Y' AND pp.IsDefault='Y'";
|
||||||
boolean error = true;
|
boolean error = true;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
pstmt.setInt(2, AD_Client_ID);
|
pstmt.setInt(2, AD_Client_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
// Name
|
// Name
|
||||||
|
@ -453,13 +458,15 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s_log.log(Level.SEVERE, "No info found " + AD_Table_ID);
|
s_log.log(Level.SEVERE, "No info found " + AD_Table_ID);
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
if (error)
|
if (error)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -503,13 +510,15 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
+ " AD_PrintColor pc, AD_PrintFont pf, AD_PrintPaper pp "
|
+ " AD_PrintColor pc, AD_PrintFont pf, AD_PrintPaper pp "
|
||||||
+ "WHERE rv.AD_ReportView_ID=? AND c.AD_Client_ID=?"
|
+ "WHERE rv.AD_ReportView_ID=? AND c.AD_Client_ID=?"
|
||||||
+ " AND pc.IsDefault='Y' AND pf.IsDefault='Y' AND pp.IsDefault='Y'";
|
+ " AND pc.IsDefault='Y' AND pf.IsDefault='Y' AND pp.IsDefault='Y'";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
boolean error = true;
|
boolean error = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, AD_ReportView_ID);
|
pstmt.setInt(1, AD_ReportView_ID);
|
||||||
pstmt.setInt(2, AD_Client_ID);
|
pstmt.setInt(2, AD_Client_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
// Name
|
// Name
|
||||||
|
@ -530,13 +539,15 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s_log.log(Level.SEVERE, "Not found: AD_ReportView_ID=" + AD_ReportView_ID);
|
s_log.log(Level.SEVERE, "Not found: AD_ReportView_ID=" + AD_ReportView_ID);
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
if (error)
|
if (error)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -567,11 +578,13 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
+ "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)"
|
+ "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)"
|
||||||
+ " AND IsEncrypted='N' AND ObscureType IS NULL "
|
+ " AND IsEncrypted='N' AND ObscureType IS NULL "
|
||||||
+ "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name";
|
+ "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, format.get_TrxName());
|
pstmt = DB.prepareStatement(sql, format.get_TrxName());
|
||||||
pstmt.setInt(1, format.getAD_Table_ID());
|
pstmt.setInt(1, format.getAD_Table_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
int seqNo = 1;
|
int seqNo = 1;
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
@ -582,13 +595,15 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
s_log.finest("Tab: " + pfi);
|
s_log.finest("Tab: " + pfi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(tab) - " + sql, e);
|
s_log.log(Level.SEVERE, "(tab) - " + sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
// No Tab found for Table
|
// No Tab found for Table
|
||||||
if (list.size() == 0)
|
if (list.size() == 0)
|
||||||
{
|
{
|
||||||
|
@ -599,9 +614,9 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
+ "ORDER BY IsIdentifier DESC, SeqNo, Name";
|
+ "ORDER BY IsIdentifier DESC, SeqNo, Name";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, format.get_TrxName());
|
pstmt = DB.prepareStatement(sql, format.get_TrxName());
|
||||||
pstmt.setInt(1, format.getAD_Table_ID());
|
pstmt.setInt(1, format.getAD_Table_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
int seqNo = 1;
|
int seqNo = 1;
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
@ -612,13 +627,15 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
s_log.finest("Table: " + pfi);
|
s_log.finest("Table: " + pfi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(table) - " + sql, e);
|
s_log.log(Level.SEVERE, "(table) - " + sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -798,6 +815,7 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
{
|
{
|
||||||
MPrintFormat retValue = null;
|
MPrintFormat retValue = null;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
String sql = "SELECT * FROM AD_PrintFormat WHERE ";
|
String sql = "SELECT * FROM AD_PrintFormat WHERE ";
|
||||||
if (AD_ReportView_ID > 0)
|
if (AD_ReportView_ID > 0)
|
||||||
sql += "AD_ReportView_ID=?";
|
sql += "AD_ReportView_ID=?";
|
||||||
|
@ -808,26 +826,17 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
pstmt.setInt (1, AD_ReportView_ID > 0 ? AD_ReportView_ID : AD_Table_ID);
|
pstmt.setInt (1, AD_ReportView_ID > 0 ? AD_ReportView_ID : AD_Table_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
retValue = new MPrintFormat (ctx, rs, null);
|
retValue = new MPrintFormat (ctx, rs, null);
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally {
|
||||||
{
|
DB.close(rs, pstmt);
|
||||||
if (pstmt != null)
|
rs = null; pstmt = null;
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // get
|
||||||
|
@ -861,19 +870,24 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
//
|
//
|
||||||
sql = MRole.getDefault().addAccessSQL (
|
sql = MRole.getDefault().addAccessSQL (
|
||||||
sql, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
sql, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
||||||
|
CPreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CPreparedStatement pstmt = DB.prepareStatement(sql, trxName);
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
if (AD_Client_ID >= 0)
|
if (AD_Client_ID >= 0)
|
||||||
pstmt.setInt(2, AD_Client_ID);
|
pstmt.setInt(2, AD_Client_ID);
|
||||||
rowSet = pstmt.getRowSet();
|
rowSet = pstmt.getRowSet();
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(pstmt);
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
return rowSet;
|
return rowSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue