[ 1801842 ] DB connection fix & improvements for concurrent threads.

This commit is contained in:
Heng Sin Low 2007-10-05 03:23:44 +00:00
parent 24bb00b332
commit 0c22a4243a
18 changed files with 335 additions and 169 deletions

View File

@ -287,7 +287,7 @@ public abstract class AbstractElementHandler implements ElementHandler {
fileTarget = new FileInputStream(filePath);
}
catch (FileNotFoundException e ) {
System.out.println("Can't find file ");
System.out.println("File not found: " + filePath);
return null;
}
@ -308,7 +308,7 @@ public abstract class AbstractElementHandler implements ElementHandler {
fileTarget = new FileOutputStream(filePath);
}
catch (FileNotFoundException e ) {
System.out.println("Can't find file ");
System.out.println("File not found: " + filePath);
return null;
}

View File

@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -66,6 +67,7 @@ public class IDFinder {
}
catch (Exception e) {
log.info ("get_ID:"+e);
throw new DatabaseAccessException(e);
}
return id;
}
@ -113,7 +115,8 @@ public class IDFinder {
pstmt = null;
}
catch (Exception e) {
log.info ("get_ID:"+e);
log.info ("get_IDWithColumn:"+e);
throw new DatabaseAccessException(e);
}
return id;
}
@ -154,6 +157,7 @@ public class IDFinder {
}
catch (Exception e) {
log.info ("get_IDWithMaster:"+e);
throw new DatabaseAccessException(e);
}
return id;
}
@ -196,6 +200,7 @@ public class IDFinder {
}
catch (Exception e) {
log.info ("get_IDWithMasterAndColumn:"+e);
throw new DatabaseAccessException(e);
}
return id;
}
@ -232,6 +237,7 @@ public class IDFinder {
}
catch (Exception e) {
log.info ("get_IDWithMasterID:"+e);
throw new DatabaseAccessException(e);
}
return id;
}
@ -269,7 +275,8 @@ public class IDFinder {
pstmt = null;
}
catch (Exception e) {
log.log(Level.SEVERE, "getID:"+e);
log.log(Level.SEVERE, "getIDbyName:"+e);
throw new DatabaseAccessException(e);
}
return id;
}

View File

@ -17,6 +17,7 @@
package org.adempiere.pipo.handler;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -36,6 +37,7 @@ import org.compiere.model.X_AD_Column;
import org.compiere.model.X_AD_Element;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Trx;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -219,9 +221,9 @@ public class ColumnElementHandler extends AbstractElementHandler {
recreateColumn = false;
}
if (tableName.equals("A_Depreciation") && columnName.equals("Processed")) {
/*if (tableName.equals("A_Depreciation") && columnName.equals("Processed")) {
System.out.println("A_Depreciation.Processed: " + recreateColumn);
}
}*/
if (m_Column.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Column", m_Column
@ -281,9 +283,15 @@ public class ColumnElementHandler extends AbstractElementHandler {
String sql = null;
ResultSet rst = null;
ResultSet rsc = null;
Connection conn = null;
Trx trx = Trx.get(getTrxName(ctx), true);
if (!trx.commit())
return 0;
try {
// Find Column in Database
DatabaseMetaData md = DB.getConnectionRO().getMetaData();
conn = trx.getConnection();
DatabaseMetaData md = conn.getMetaData();
String catalog = DB.getDatabase().getCatalog();
String schema = DB.getDatabase().getSchema();
String tableName = table.getTableName();
@ -327,14 +335,16 @@ public class ColumnElementHandler extends AbstractElementHandler {
log.info(sql);
if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) {
no = DB.executeUpdate(sql, false, getTrxName(ctx));
System.out.println(sql);
no = DB.executeUpdate(sql, false, trx.getTrxName());
if (no == -1)
return 0;
} else {
String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
for (int i = 0; i < statements.length; i++) {
System.out.println(statements[i]);
int count = DB.executeUpdate(statements[i], false,
getTrxName(ctx));
trx.getTrxName());
if (count == -1) {
return 0;
}
@ -342,6 +352,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
}
}
}
trx.commit(true);
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
if (rsc != null) {
@ -358,19 +369,10 @@ public class ColumnElementHandler extends AbstractElementHandler {
}
rst = null;
}
trx.rollback();
return 0;
}
// postgres requires commit on DDL (ALTER,CREATE)
if (DB.isPostgreSQL()) {
try {
DB.commit(true, getTrxName(ctx));
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return 0;
}
}
return 1;
}

View File

@ -142,6 +142,7 @@ public class ProcessElementHandler extends AbstractElementHandler {
.get_ID(), AD_Backup_ID, Object_Status, "AD_Process",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Process"));
element.recordId = m_Process.getAD_Process_ID();
} else {
record_log(ctx, 0, m_Process.getName(), "Process", m_Process
.get_ID(), AD_Backup_ID, Object_Status, "AD_Process",

View File

@ -41,10 +41,38 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.getElementValue().equals("process") &&
element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name");
int id = get_IDWithMaster(ctx, "AD_Process_Para", name,
"AD_Process", atts.getValue("ADProcessNameID"));
int id = 0;
int masterId = 0;
String processValue = "";
if (element.parent != null && element.parent.getElementValue().equals("process") &&
element.parent.recordId > 0) {
masterId = element.parent.recordId;
} else {
processValue = atts.getValue("ADProcessValueID");
if (processValue != null && processValue.trim().length() > 0) {
masterId = get_IDWithColumn(ctx, "AD_Process", "Value", processValue);
} else {
//for backward compatibility
processValue = atts.getValue("ADProcessNameID");
masterId = get_IDWithColumn(ctx, "AD_Process", "Name", processValue);
}
}
if (masterId <= 0) {
element.defer = true;
element.unresolved = "AD_Process: " + processValue;
return;
}
id = get_IDWithMasterAndColumn(ctx, "AD_Process_Para", "Name",
name, "AD_Process", masterId);
X_AD_Process_Para m_Process_para = new X_AD_Process_Para(ctx, id,
getTrxName(ctx));
int AD_Backup_ID = -1;
@ -58,14 +86,8 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
AD_Backup_ID = 0;
}
m_Process_para.setName(atts.getValue("Name"));
name = atts.getValue("ADProcessNameID");
id = get_IDWithColumn(ctx, "AD_Process", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Process: " + name;
return;
}
m_Process_para.setAD_Process_ID(id);
m_Process_para.setAD_Process_ID(masterId);
m_Process_para.setColumnName(atts.getValue("ColumnName"));
m_Process_para.setEntityType(atts.getValue("EntityType"));
@ -200,12 +222,12 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
(m_Processpara.getName() != null ? m_Processpara
.getName() : ""));
if (m_Processpara.getAD_Process_ID() > 0) {
sql = "SELECT Name FROM AD_Process WHERE AD_Process_ID=?";
sql = "SELECT Value FROM AD_Process WHERE AD_Process_ID=?";
name = DB.getSQLValueString(null, sql, m_Processpara
.getAD_Process_ID());
atts.addAttribute("", "", "ADProcessNameID", "CDATA", name);
atts.addAttribute("", "", "ADProcessValueID", "CDATA", name);
} else
atts.addAttribute("", "", "ADProcessNameID", "CDATA", "");
atts.addAttribute("", "", "ADProcessValueID", "CDATA", "");
if (m_Processpara.getAD_Process_Para_ID() > 0) {
sql = "SELECT Name FROM AD_Process_Para WHERE AD_Process_Para_ID=?";
name = DB.getSQLValueString(null, sql, m_Processpara

View File

@ -90,6 +90,7 @@ public class ReferenceElementHandler extends AbstractElementHandler {
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
references.add(m_Reference.getAD_Reference_ID());
element.recordId = m_Reference.getAD_Reference_ID();
} else {
record_log(ctx, 0, m_Reference.getName(), "Reference",
m_Reference.get_ID(), AD_Backup_ID, Object_Status,

View File

@ -48,8 +48,15 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
}
String name = atts.getValue("Name");
String value = atts.getValue("Value");
int AD_Reference_ID = get_IDWithColumn(ctx, "AD_Reference", "Name",
int AD_Reference_ID = 0;
if (element.parent != null && element.parent.getElementValue().equals("reference") &&
element.parent.recordId > 0) {
AD_Reference_ID = element.parent.recordId;
} else {
AD_Reference_ID = get_IDWithColumn(ctx, "AD_Reference", "Name",
atts.getValue("ADRefenceNameID"));
}
int AD_Ref_List_ID = get_IDWithMasterAndColumn(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID,
getTrxName(ctx));

View File

@ -54,12 +54,19 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
return;
}
int AD_Reference_ID = 0;
if (element.parent != null && element.parent.getElementValue().equals("reference") &&
element.parent.recordId > 0) {
AD_Reference_ID = element.parent.recordId;
} else {
StringBuffer sqlB = new StringBuffer(
"SELECT AD_Reference_ID FROM AD_Reference WHERE Name= ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name);
sqlB = new StringBuffer(
AD_Reference_ID = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name);
}
StringBuffer sqlB = new StringBuffer(
"SELECT Count(*) FROM AD_Ref_Table WHERE AD_Reference_ID= ?");
int count = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), id);
int count = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), AD_Reference_ID);
int tableId = get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID"));
if (tableId == 0) {
@ -141,17 +148,17 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
"', OrderByClause = '" + OrderByClause).append(
"', EntityType ='" + entityType).append(
"', WhereClause = '" + WhereClause).append(
"' WHERE AD_Reference_ID = " + id);
"' WHERE AD_Reference_ID = " + AD_Reference_ID);
int no = DB.executeUpdate(sqlB.toString(), getTrxName(ctx));
if (no > 0) {
record_log(ctx, 1, atts.getValue("ADRefenceNameID"),
"Reference Table", id, 0, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
} else {
record_log(ctx, 0, atts.getValue("ADRefenceNameID"),
"Reference Table", id, 0, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");
@ -165,7 +172,7 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
.append(
",entityType, isValueDisplayed, OrderByClause, ")
.append(" WhereClause )").append(
"VALUES(0, 0, 0, 0, " + id).append(
"VALUES(0, 0, 0, 0, " + AD_Reference_ID).append(
", " + tableId).append(", " + DisplayId)
.append(", " + keyId).append(", '" + entityType)
.append("', '" + isValueDisplayed).append(
@ -175,12 +182,12 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
int no = DB.executeUpdate(sqlB.toString(), getTrxName(ctx));
if (no > 0) {
record_log(ctx, 1, atts.getValue("ADRefenceNameID"),
"Reference Table", id, 0, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
} else {
record_log(ctx, 0, atts.getValue("ADRefenceNameID"),
"Reference Table", id, 0, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");

View File

@ -45,7 +45,13 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
if (isProcessElement(ctx, entitytype)) {
String name = atts.getValue("ADReportviewNameID");
int AD_ReportView_ID = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
int AD_ReportView_ID = 0;
if (element.parent != null && element.parent.getElementValue().equals("reportview") &&
element.parent.recordId > 0) {
AD_ReportView_ID = element.parent.recordId;
} else {
AD_ReportView_ID = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
}
if (AD_ReportView_ID <= 0) {
element.defer = true;
return;

View File

@ -97,6 +97,7 @@ public class ReportViewElementHandler extends AbstractElementHandler {
m_Reportview.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reportview", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reportview"));
element.recordId = m_Reportview.getAD_ReportView_ID();
} else {
record_log(ctx, 0, m_Reportview.getName(), "Reportview",
m_Reportview.get_ID(), AD_Backup_ID, Object_Status,

View File

@ -60,12 +60,16 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
// pstmt.executeUpdate();
//
Connection m_con = DB.getConnectionRW(true);
try {
Statement stmt = m_con.createStatement();
int n = stmt.executeUpdate (atts.getValue("statement"));
log.info("Executed SQL Statement for PostgreSQL: "+ atts.getValue("statement"));
// Postgres needs to commit DDL statements
if (m_con != null && !m_con.getAutoCommit())
m_con.commit();
} finally {
m_con.close();
}
}
/* else if(DB.isSybase() == true && DBType.equals("Sybase")){
pstmt.executeUpdate();

View File

@ -547,6 +547,7 @@ public class DB_Oracle implements AdempiereDatabase
try
{
System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
//System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL");
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDataSourceName("AdempiereDS");
cpds.setDriverClass(DRIVER);
@ -555,8 +556,10 @@ public class DB_Oracle implements AdempiereDatabase
cpds.setUser(connection.getDbUid());
cpds.setPassword(connection.getDbPwd());
cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
cpds.setIdleConnectionTestPeriod(120);
cpds.setIdleConnectionTestPeriod(1200);
cpds.setAcquireRetryAttempts(5);
//cpds.setTestConnectionOnCheckin(true);
//cpds.setTestConnectionOnCheckout(true);
//cpds.setCheckoutTimeout(60);
if (Ini.isClient())
@ -565,7 +568,7 @@ public class DB_Oracle implements AdempiereDatabase
cpds.setMinPoolSize(1);
cpds.setMaxPoolSize(15);
cpds.setMaxIdleTimeExcessConnections(1200);
cpds.setMaxIdleTime(600);
cpds.setMaxIdleTime(900);
m_maxbusyconnections = 12;
}
else
@ -574,12 +577,13 @@ public class DB_Oracle implements AdempiereDatabase
cpds.setMinPoolSize(5);
cpds.setMaxPoolSize(150);
cpds.setMaxIdleTimeExcessConnections(1200);
cpds.setMaxIdleTime(900);
cpds.setMaxIdleTime(1200);
m_maxbusyconnections = 120;
}
cpds.setUnreturnedConnectionTimeout(1200);
cpds.setDebugUnreturnedConnectionStackTraces(true);
//the following sometimes kill active connection!
//cpds.setUnreturnedConnectionTimeout(1200);
//cpds.setDebugUnreturnedConnectionStackTraces(true);
m_ds = cpds;
}

View File

@ -504,6 +504,9 @@ public class DB_PostgreSQL implements AdempiereDatabase
getDataSource(connection);
//
Connection conn = m_ds.getConnection();
ComboPooledDataSource cpds = (ComboPooledDataSource)m_ds;
//System.out.println("Num Connections: " + cpds.getNumConnections() + ", Busy Connections: "
// + cpds.getNumBusyConnections());
// Connection conn = getDriverConnection(connection);
//
conn.setAutoCommit(autoCommit);
@ -519,13 +522,13 @@ public class DB_PostgreSQL implements AdempiereDatabase
*/
public DataSource getDataSource(CConnection connection)
{
//throw new UnsupportedOperationException("Not supported/implemented");
if (m_ds != null)
return m_ds;
try
{
System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
//System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL");
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDataSourceName("AdempiereDS");
cpds.setDriverClass(DRIVER);
@ -534,7 +537,9 @@ public class DB_PostgreSQL implements AdempiereDatabase
cpds.setUser(connection.getDbUid());
cpds.setPassword(connection.getDbPwd());
cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
cpds.setIdleConnectionTestPeriod(120);
cpds.setIdleConnectionTestPeriod(1200);
//cpds.setTestConnectionOnCheckin(true);
//cpds.setTestConnectionOnCheckout(true);
cpds.setAcquireRetryAttempts(5);
//cpds.setCheckoutTimeout(60);
@ -544,7 +549,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
cpds.setMinPoolSize(1);
cpds.setMaxPoolSize(15);
cpds.setMaxIdleTimeExcessConnections(1200);
cpds.setMaxIdleTime(600);
cpds.setMaxIdleTime(900);
m_maxbusyconnections = 12;
}
else
@ -553,12 +558,13 @@ public class DB_PostgreSQL implements AdempiereDatabase
cpds.setMinPoolSize(5);
cpds.setMaxPoolSize(150);
cpds.setMaxIdleTimeExcessConnections(1200);
cpds.setMaxIdleTime(900);
cpds.setMaxIdleTime(1200);
m_maxbusyconnections = 120;
}
cpds.setUnreturnedConnectionTimeout(1200);
cpds.setDebugUnreturnedConnectionStackTraces(true);
//the following sometimes kill active connection!
//cpds.setUnreturnedConnectionTimeout(1200);
//cpds.setDebugUnreturnedConnectionStackTraces(true);
m_ds = cpds;
}

View File

@ -141,10 +141,10 @@ public class MChangeLog extends X_AD_ChangeLog
int AD_Client_ID, int AD_Org_ID,
Object OldValue, Object NewValue)
{
this (ctx, 0, null); // out of trx
this (ctx, 0, TrxName);
if (AD_ChangeLog_ID == 0)
{
AD_ChangeLog_ID = DB.getNextID (AD_Client_ID, Table_Name, null);
AD_ChangeLog_ID = DB.getNextID (AD_Client_ID, Table_Name, TrxName);
if (AD_ChangeLog_ID <= 0)
log.severe("No NextID (" + AD_ChangeLog_ID + ")");
}

View File

@ -695,6 +695,19 @@ public abstract class PO
else if (value.getClass() == Integer.class
&& p_info.getColumnClass(index) == String.class)
m_newValues[index] = value;
else if (value.getClass() == String.class
&& p_info.getColumnClass(index) == Integer.class)
try
{
m_newValues[index] = new Integer((String)value);
}
catch (NumberFormatException e)
{
log.log(Level.SEVERE, ColumnName
+ " - Class invalid: " + value.getClass().toString()
+ ", Should be " + p_info.getColumnClass(index).toString() + ": " + value);
return false;
}
else
{
log.log(Level.SEVERE, ColumnName
@ -1817,12 +1830,24 @@ public abstract class PO
setAD_Org_ID(0);
}
}
Trx localTrx = null;
if (m_trxName == null) {
m_trxName = Trx.createTrxName("POSave");
localTrx = Trx.get(m_trxName, true);
}
// Before Save
try
{
if (!beforeSave(newRecord))
{
log.warning("beforeSave failed - " + toString());
if (localTrx != null) {
localTrx.rollback();
localTrx.close();
m_trxName = null;
}
return false;
}
}
@ -1830,9 +1855,15 @@ public abstract class PO
{
log.log(Level.WARNING, "beforeSave - " + toString(), e);
log.saveError("Error", e.toString(), false);
// throw new DBException(e);
if (localTrx != null) {
localTrx.rollback();
localTrx.close();
m_trxName = null;
}
return false;
}
try {
// Call ModelValidators TYPE_NEW/TYPE_CHANGE
String errorMsg = ModelValidationEngine.get().fireModelChange
(this, newRecord ? ModelValidator.TYPE_NEW : ModelValidator.TYPE_CHANGE);
@ -1840,13 +1871,54 @@ public abstract class PO
{
log.warning("Validation failed - " + errorMsg);
log.saveError("Error", errorMsg);
if (localTrx != null) {
localTrx.rollback();
m_trxName = null;
}
return false;
}
// Save
if (newRecord)
return saveNew();
{
boolean b = saveNew();
if (b)
{
if (localTrx != null)
return localTrx.commit();
else
return saveUpdate();
return b;
}
else
{
if (localTrx != null)
localTrx.rollback();
return b;
}
}
else
{
boolean b = saveUpdate();
if (b)
{
if (localTrx != null)
return localTrx.commit();
else
return b;
}
else
{
if (localTrx != null)
localTrx.rollback();
return b;
}
}
} finally {
if (localTrx != null)
{
localTrx.close();
m_trxName = null;
}
}
} // save
/**

View File

@ -70,7 +70,10 @@ public class ColumnSync extends SvrProcess
throw new AdempiereUserError("@NotFound@ @AD_Table_ID@ " + column.getAD_Table_ID());
// Find Column in Database
DatabaseMetaData md = DB.getConnectionRO().getMetaData();
Connection conn = null;
try {
conn = DB.getConnectionRO();
DatabaseMetaData md = conn.getMetaData();
String catalog = DB.getDatabase().getCatalog();
String schema = DB.getDatabase().getSchema();
String tableName = table.getTableName();
@ -135,6 +138,13 @@ public class ColumnSync extends SvrProcess
throw new AdempiereUserError (msg);
}
return sql;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {}
}
}
} // doIt
} // ColumnSync

View File

@ -81,7 +81,10 @@ public class TableCreateColumns extends SvrProcess
+ ", AllTables=" + p_AllTables
+ ", AD_Table_ID=" + p_AD_Table_ID);
//
Connection conn = DB.getConnectionRO();
Connection conn = null;
try {
conn = DB.getConnectionRO();
AdempiereDatabase db = DB.getDatabase();
DatabaseMetaData md = conn.getMetaData();
String catalog = db.getCatalog();
@ -107,6 +110,13 @@ public class TableCreateColumns extends SvrProcess
}
return "#" + m_count;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {}
}
}
} // doIt
/**

View File

@ -152,11 +152,17 @@ public class Login
Env.setContext(m_ctx, "#Host", cc.getAppsHost());
Env.setContext(m_ctx, "#Database", cc.getDbName());
if (DB.getConnectionRO() == null)
Connection conn = DB.getConnectionRO();
if (conn == null)
{
log.saveError("NoDatabase", "");
return null;
}
try {
conn.close();
} catch (SQLException e) {
}
if (app_pwd == null)
return null;
//