C3P0 DBCP DRUID
public class JDBCUtils { private static DataSource c3p0DataSource = new ComboPooledDataSource("testC3P0"); public static Connection getC3P0Connection() throws SQLException { Connection connection = c3p0DataSource.getConnection(); return connection; } private static DataSource dbcpDataSource; static { InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("dbcp.properties"); Properties properties = new Properties(); try { properties.load(is); dbcpDataSource = BasicDataSourceFactory.createDataSource(properties); } catch (Exception e) { e.printStackTrace(); } } public static Connection getDBCPConnection() throws SQLException { Connection connection = dbcpDataSource.getConnection(); return connection; } private static DataSource druidDataSource; static { InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream("druid.properties"); Properties properties = new Properties(); try { properties.load(resourceAsStream); druidDataSource = DruidDataSourceFactory.createDataSource(properties); } catch (Exception e) { e.printStackTrace(); } } public static Connection getDRUIDConnection() throws SQLException { Connection connection = druidDataSource.getConnection(); return connection; } }