Here you can find the source of getDBConnection()
static Connection getDBConnection() throws SQLException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; public class Main { private static Connection connection = null; static Connection getDBConnection() throws SQLException, ClassNotFoundException { if (connection == null) connection = connectToDatabase(); return connection; }//from ww w.j av a 2 s .c o m static Connection connectToDatabase() throws SQLException, ClassNotFoundException { Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://localhost/autoeval"; Properties props = new Properties(); props.setProperty("user", "dude"); props.setProperty("password", "supersecret"); // props.setProperty("ssl", "false"); return DriverManager.getConnection(url, props); } }