Here you can find the source of getConnection()
public static Connection getConnection()
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { private static String url = "jdbc:mysql://127.0.0.1:3306/bjwg_test"; private static String user = "root"; private static String psw = "root"; private static Connection conn; public static Connection getConnection() { if (null == conn) { try { conn = DriverManager.getConnection(url, user, psw); } catch (SQLException e) { e.printStackTrace();/* w w w. j ava2 s. c om*/ throw new RuntimeException(e); } } return conn; } }