wood burning stoves*
The moose likes JDBC and the fly likes ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit" Watch "ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit" New topic
Author

ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit

Kuyni Kumar
Greenhorn

Joined: Jan 18, 2011
Posts: 14
In my jdbc application I am getting above error, Can you please tell me what is the main reason behind it.

private static void initializeConnection() {
try {
EnvironmentProperties envProperties = DatabaseProperties.envProperties;

String str = envProperties.getDbdriver() + " "
+ envProperties.getDburl() + envProperties.getUserName()
+ envProperties.getPassword();

logger.info(str);

Class.forName(envProperties.getDbdriver());
DBManager.connection = DriverManager.getConnection(
envProperties.getDburl(), envProperties.getUserName(),
envProperties.getPassword());

logger.info("CREATED THE SUCCESSFUL DB CONNECTION!");
} catch (ClassNotFoundException classE) {
logger.error(classE);
// classE.printStackTrace();
} catch (SQLException sqlE) {
logger.error(sqlE);
// sqlE.printStackTrace();
} catch (Exception e) {
logger.error(e);
// e.printStackTrace();
}
}
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Oracle's error's are usually easily searchable: ORA-02391.

The underlying cause probably is that your application has created too many connections. Your initConnection function creates a new connection, does nothing with it and does not close it (do you call it repeatedly?). Always close connections properly in the finally section.



Kuyni Kumar
Greenhorn

Joined: Jan 18, 2011
Posts: 14
public class DatabaseFactory implements DataBaseFactoryInterface {

/*
* Create the Database Connection
*
* @see com.cisco.dbts.model.base.DataBaseFactoryInterface#getDBConnection()
*/
public Connection getDBConnection() throws SQLException {

DatabaseProperties.loadProperties();
return DBManager.getConnection();
}

/*
* Close the Database connection if open
*
* @see
* com.cisco.dbts.model.base.DataBaseFactoryInterface#closeDBConnection(
* java.sql.Connection)
*/
public void closeDBConnection(Connection connection) {
if (connection == null) {
return;
}
try {
//System.out.println(connection);
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

}

The above is my class - which is having closeDBConnection and getDBConnection methods.
But my question is , even I close all the connections. Still it is in idle state from the oracle side.
also. If I close connection my client side will it also close the connection on oracle side.
If not how to acheive that. Is connection pool will help in that?
Kuyni Kumar
Greenhorn

Joined: Jan 18, 2011
Posts: 14
I got the solution. There is nothing wrong from the code.
This usually happens when you have limited number of connections available from Database. The number of connection will be maintained by the Database Admin.
At enterprise level, It is not possible to provide unlimited connection to the every team on the same database. Hence when we reach that limit it will through the above mentioned error.
Hence the solution for this problem is to have a good connection pool mechanism else have a connection pool datasource in your application server.

Thanks
Rajesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit
 
Similar Threads
Reading remote file - difference between linux and windows deployments
Runtime.getRuntime block question
Validator ignore integers with spaces
Reflection Problem - I feel like a Vampire... No reflection found...
Limit on Data/Key-Value Pairs in Form Submission