0

我想知道如何调整我的本地 Oracle DB 设置以通过我的 Web 应用程序获取此错误。任何投入将不胜感激。

谢谢。我更改了用户的个人资料:

ALTER PROFILE cashnet LIMIT 
    SESSIONS_PER_USER          UNLIMITED 
    CPU_PER_SESSION            UNLIMITED 
    CPU_PER_CALL               3000 
    CONNECT_TIME               1 
    IDLE_TIME                  1
    LOGICAL_READS_PER_SESSION  DEFAULT 
    LOGICAL_READS_PER_CALL     1000 
    PRIVATE_SGA                15K
    COMPOSITE_LIMIT            5000000;

protected Properties getDefaultConnectionProps()
{
    Properties prop = new Properties ();`
    prop.setProperty("MinLimit", "1");     // the cache size is 5 at least 
    prop.setProperty("MaxLimit", "1");
    prop.setProperty("InitialLimit", "2"); // create 3 connections at startup
    prop.setProperty("InactivityTimeout", "1");    //  seconds
    prop.setProperty("TimeToLiveTimeout","30"); 
    prop.setProperty("AbandonedConnectionTimeout", "900");  //  seconds
    prop.setProperty("MaxStatementsLimit", "10");
    prop.setProperty("ValidateConnection","true");
    prop.setProperty("PropertyCheckInterval", "60"); // seconds
    System.out.println("[OracleConnector2.getDefaultConnectionProps] Setting properties");
    prop.setProperty("oracle.net.READ_TIMEOUT", "1");
    return prop;
}

public Connection getConnection() throws SQLException
{
    OracleConnectionPoolDataSource ocpds
        = (OracleConnectionPoolDataSource)_pooledConnections.get(getConectionId());
    if(ocpds == null){
        ocpds = new OracleConnectionPoolDataSource();
        ocpds.setURL(_url);
        ocpds.setUser(_user);
        ocpds.setPassword(_password);
        Properties prop = getDefaultConnectionProps();
        if (_readtimeout != null){
            _connectionProps.setProperty("oracle.jdbc.ReadTimeout", _readtimeout + "000");
        }
        else{
            _connectionProps.setProperty("oracle.jdbc.ReadTimeout", "20000");
        }
        // clean up connection props for OAS
        _connectionProps.remove("oracle.net.encryption_client");
        _connectionProps.remove("oracle.net.encryption_types_client");
        _connectionProps.remove("oracle.net.crypto_checksum_client");
        _connectionProps.remove("oracle.net.crypto_checksum_types_client");
        prop.putAll(_connectionProps);
        ocpds.setConnectionCacheProperties (prop);  // set properties
        _pooledConnections.put(getConectionId(),ocpds);
    }
    System.out.println("[OracleConnector2.getConnection] Setting timeout");
    if (_logintimeout != null){
        ocpds.setLoginTimeout(Integer.parseInt(_logintimeout.trim()));
    }else{
        ocpds.setLoginTimeout(10);
    }
    PooledConnection pc = ocpds.getPooledConnection(_user,_password);
    return pc.getConnection();
}
4

1 回答 1

0

有多种方法。最简单的方法是终止当前位于连接池中的连接的数据库会话。如果出于某种原因,您想强制该错误持续发生,我想您可以修改Oracle 数据库用户的配置文件以设置一个IDLE_TIME(假设您的应用程序在连接池中维护连接一段合理的时间时间)。

于 2013-05-20T22:56:47.237 回答