Here you can find the source of getConnection()
public static Connection getConnection()
//package com.java2s; /*L//w w w .j a v a2 s . c o m * Copyright Georgetown University, Washington University. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cab2b/LICENSE.txt for details. */ import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; public class Main { private final static String driver = "com.mysql.jdbc.Driver"; private static Properties serverProperties; public static Connection getConnection() { String ip = serverProperties.getProperty("database.server.ip"); String port = serverProperties.getProperty("database.server.port"); String name = serverProperties.getProperty("database.name"); String userName = serverProperties.getProperty("database.username"); String password = serverProperties.getProperty("database.password"); String url = "jdbc:mysql://" + ip + ":" + port + "/" + name + ""; Connection con = null; try { Class.forName(driver).newInstance(); con = DriverManager.getConnection(url, userName, password); } catch (Exception e) { e.printStackTrace(); } if (con == null) System.out.println("Got null connection"); return con; } }