Java JDBC Connection Pool getConnection()

Here you can find the source of getConnection()

Description

Helper method to get a connection from the connection pool.

License

Open Source License

Exception

Parameter Description
SQLException iff something goes wrong.

Return

A connection from the connection pool.

Declaration

public static Connection getConnection() throws Exception 

Method Source Code

//package com.java2s;

import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
    private static boolean driverSetup = false;

    /**/*from ww w . j a v a 2s.co  m*/
     * Helper method to get a connection from the connection pool.
     * 
     * @return A connection from the connection pool.
     * @throws SQLException
     *             iff something goes wrong.
     */
    public static Connection getConnection() throws Exception {
        if (!driverSetup) {
            throw new Exception("Driver has not been set up with a call to setupDriver().");
        }

        return DriverManager.getConnection("jdbc:apache:commons:dbcp:local");
    }
}

Related

  1. getConnectionFromPool()
  2. getDatabaseConnection(String propertiesFile)