Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit

 
Kuyni Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic