Here you can find the source of getConnection()
Parameter | Description |
---|---|
SQLException | iff something goes wrong. |
public static Connection getConnection() throws Exception
//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"); } }