[ 1839065 ] Connection dialog hang if database parameter is not valid
This commit is contained in:
parent
cb12d009c1
commit
98a49b22b5
|
@ -1320,24 +1320,6 @@ public class CConnection implements Serializable, Cloneable
|
||||||
{
|
{
|
||||||
ee = e;
|
ee = e;
|
||||||
}
|
}
|
||||||
if (conn == null)
|
|
||||||
{
|
|
||||||
Thread.yield();
|
|
||||||
log.config("retrying - " + ee);
|
|
||||||
conn = m_db.getCachedConnection(this, autoCommit, transactionIsolation);
|
|
||||||
}
|
|
||||||
// System.err.println ("CConnection.getConnection(Cache) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
|
|
||||||
// }
|
|
||||||
// else if (isDataSource()) // Client
|
|
||||||
// {
|
|
||||||
// conn = m_ds.getConnection();
|
|
||||||
// System.err.println ("CConnection.getConnection(DataSource) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// conn = m_db.getDriverConnection (this);
|
|
||||||
// System.err.println ("CConnection.getConnection(Driver) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
|
|
||||||
// }
|
|
||||||
// Verify Connection
|
// Verify Connection
|
||||||
if (conn != null)
|
if (conn != null)
|
||||||
{
|
{
|
||||||
|
@ -1359,10 +1341,17 @@ public class CConnection implements Serializable, Cloneable
|
||||||
{
|
{
|
||||||
m_dbException = ex;
|
m_dbException = ex;
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
|
{
|
||||||
|
//log might cause infinite loop since it will try to acquire database connection again
|
||||||
|
/*
|
||||||
log.log(Level.SEVERE, getConnectionURL ()
|
log.log(Level.SEVERE, getConnectionURL ()
|
||||||
+ ", (1) AutoCommit=" + autoCommit + ",TrxIso=" + getTransactionIsolationInfo(transactionIsolation)
|
+ ", (1) AutoCommit=" + autoCommit + ",TrxIso=" + getTransactionIsolationInfo(transactionIsolation)
|
||||||
// + " (" + getDbUid() + "/" + getDbPwd() + ")"
|
|
||||||
+ " - " + ex.getMessage());
|
+ " - " + ex.getMessage());
|
||||||
|
*/
|
||||||
|
System.err.println(getConnectionURL ()
|
||||||
|
+ ", (1) AutoCommit=" + autoCommit + ",TrxIso=" + getTransactionIsolationInfo(transactionIsolation)
|
||||||
|
+ " - " + ex.getMessage());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1385,7 +1374,9 @@ public class CConnection implements Serializable, Cloneable
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_dbException = ex;
|
m_dbException = ex;
|
||||||
log.log(Level.SEVERE, getConnectionURL(), ex);
|
//log might cause infinite loop since it will try to acquire database connection again
|
||||||
|
//log.log(Level.SEVERE, getConnectionURL(), ex);
|
||||||
|
System.err.println(getConnectionURL() + " - " + ex.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
// System.err.println ("CConnection.getConnection - " + conn);
|
// System.err.println ("CConnection.getConnection - " + conn);
|
||||||
return conn;
|
return conn;
|
||||||
|
|
|
@ -558,7 +558,7 @@ public class DB_Oracle implements AdempiereDatabase
|
||||||
cpds.setPassword(connection.getDbPwd());
|
cpds.setPassword(connection.getDbPwd());
|
||||||
cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
|
cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
|
||||||
cpds.setIdleConnectionTestPeriod(1200);
|
cpds.setIdleConnectionTestPeriod(1200);
|
||||||
cpds.setAcquireRetryAttempts(5);
|
cpds.setAcquireRetryAttempts(2);
|
||||||
//cpds.setTestConnectionOnCheckin(true);
|
//cpds.setTestConnectionOnCheckin(true);
|
||||||
//cpds.setTestConnectionOnCheckout(true);
|
//cpds.setTestConnectionOnCheckout(true);
|
||||||
//cpds.setCheckoutTimeout(60);
|
//cpds.setCheckoutTimeout(60);
|
||||||
|
@ -591,7 +591,9 @@ public class DB_Oracle implements AdempiereDatabase
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_ds = null;
|
m_ds = null;
|
||||||
log.log(Level.SEVERE, "Could not initialise C3P0 Datasource", ex);
|
//log might cause infinite loop since it will try to acquire database connection again
|
||||||
|
//log.log(Level.SEVERE, "Could not initialise C3P0 Datasource", ex);
|
||||||
|
System.err.println("Could not initialise C3P0 Datasource: " + ex.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_ds;
|
return m_ds;
|
||||||
|
@ -617,14 +619,7 @@ public class DB_Oracle implements AdempiereDatabase
|
||||||
if (m_ds == null)
|
if (m_ds == null)
|
||||||
getDataSource(connection);
|
getDataSource(connection);
|
||||||
|
|
||||||
|
|
||||||
// Properties connAttr = new Properties();
|
|
||||||
// connAttr.setProperty("TRANSACTION_ISOLATION", CConnection.getTransactionIsolationInfo(transactionIsolation));
|
|
||||||
// OracleConnection conn = (OracleConnection)m_ds.getConnection(connAttr);
|
|
||||||
//
|
//
|
||||||
// Try 5 times max
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = (Connection)m_ds.getConnection();
|
conn = (Connection)m_ds.getConnection();
|
||||||
|
@ -644,60 +639,42 @@ public class DB_Oracle implements AdempiereDatabase
|
||||||
if (e instanceof SQLException
|
if (e instanceof SQLException
|
||||||
&& ((SQLException)e).getErrorCode() == 1017) // invalid username/password
|
&& ((SQLException)e).getErrorCode() == 1017) // invalid username/password
|
||||||
{
|
{
|
||||||
|
//log might cause infinite loop since it will try to acquire database connection again
|
||||||
|
/*
|
||||||
log.severe("Cannot connect to database: "
|
log.severe("Cannot connect to database: "
|
||||||
+ getConnectionURL(connection)
|
+ getConnectionURL(connection)
|
||||||
+ " - UserID=" + connection.getDbUid());
|
+ " - UserID=" + connection.getDbUid());
|
||||||
break;
|
*/
|
||||||
|
System.err.println("Cannot connect to database: "
|
||||||
|
+ getConnectionURL(connection)
|
||||||
|
+ " - UserID=" + connection.getDbUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
if (conn != null && conn.isClosed())
|
|
||||||
conn = null;
|
|
||||||
// OK
|
|
||||||
if (conn != null && !conn.isClosed())
|
|
||||||
break;
|
|
||||||
if (i == 0)
|
|
||||||
Thread.yield(); // give some time
|
|
||||||
else
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
exception = e;
|
|
||||||
conn = null;
|
|
||||||
}
|
|
||||||
} // 5 tries
|
|
||||||
|
|
||||||
if (conn == null && exception != null)
|
if (conn == null && exception != null)
|
||||||
{
|
{
|
||||||
|
//log might cause infinite loop since it will try to acquire database connection again
|
||||||
|
/*
|
||||||
log.log(Level.SEVERE, exception.toString());
|
log.log(Level.SEVERE, exception.toString());
|
||||||
log.fine(toString());
|
log.fine(toString()); */
|
||||||
// log.finest("Reference=" + m_ds.getReference());
|
System.err.println(exception.toString());
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// System.out.println(conn + " " + getStatus());
|
|
||||||
// conn.registerConnectionCacheCallback(this, "test", OracleConnection.ALL_CONNECTION_CALLBACKS);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// System.err.println ("DB_Oracle.getCachedConnection");
|
|
||||||
// if (!(e instanceof SQLException))
|
|
||||||
// e.printStackTrace();
|
|
||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (conn != null) {
|
||||||
int numConnections = m_ds.getNumBusyConnections();
|
int numConnections = m_ds.getNumBusyConnections();
|
||||||
//if (numConnections > m_maxbusyconnections)
|
if(numConnections >= m_maxbusyconnections )
|
||||||
if(numConnections % 10 == 0)
|
|
||||||
{
|
{
|
||||||
log.warning(getStatus());
|
log.warning(getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -541,7 +541,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
||||||
cpds.setIdleConnectionTestPeriod(1200);
|
cpds.setIdleConnectionTestPeriod(1200);
|
||||||
//cpds.setTestConnectionOnCheckin(true);
|
//cpds.setTestConnectionOnCheckin(true);
|
||||||
//cpds.setTestConnectionOnCheckout(true);
|
//cpds.setTestConnectionOnCheckout(true);
|
||||||
cpds.setAcquireRetryAttempts(5);
|
cpds.setAcquireRetryAttempts(2);
|
||||||
//cpds.setCheckoutTimeout(60);
|
//cpds.setCheckoutTimeout(60);
|
||||||
|
|
||||||
if (Ini.isClient())
|
if (Ini.isClient())
|
||||||
|
|
Loading…
Reference in New Issue