How to get the Max Connections to Database?

Below Java code shows how to get Max concurrent connections to database –

 * Created on 05-2011 Copyright(c) All Rights Reserved.
package com.kodehelp.javasql;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

 * Created by
 * Date: 5/9/11
public class GetMaxConnections {
    public static void main(String args[]) throws SQLException, ClassNotFoundException {
        Connection conn =null;
            final String driver = "oracle.jdbc.driver.OracleDriver";
            final String url = "jdbc:oracle:thin:@HOST:PORT:SID";
            final String USERNAME = "USERNAME";
            final String PASSWORD = "PASSWORD";
            Class.forName(driver); // load Oracle driver
            conn = DriverManager.getConnection(url, USERNAME, PASSWORD);
            DatabaseMetaData metadata = conn.getMetaData();

            // Get the information of maximum concurrent connection to the
            // database. The maximum number of active connections possible at
            // one time; a result of zero means that there is no limit or the
            // limit is not known
            int maxConnection = metadata.getMaxConnections();
            System.out.println("Maximum Connection = " + maxConnection);
        }catch (SQLException sqlEx){
            throw sqlEx;
        }catch (ClassNotFoundException cnfEx){
            throw cnfEx;


Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.