Here you can find the source of getConnection()
public static Connection getConnection()
//package com.java2s; //License from project: Open Source License import java.sql.*; public class Main { private static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; private static final String DB_URL = "jdbc:mysql://52.78.111.144:3306/unichat"; private static final String USER = "jbkim"; private static final String PASS = "1q2w3e4r!!"; private static Connection conn = null; public static Connection getConnection() { if (conn != null) { return conn; }//w w w .ja v a 2s . co m try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(DB_URL, USER, PASS); } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); } return conn; } }