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 final String strUrl = "jdbc:mysql://172.21.101.175:60001/uplus?autoReconnect=true&UseUnicode=true&" + "characterEncoding=utf8"; private static final String strDriver = "com.mysql.jdbc.Driver"; private static final String strMySQLUsername = "cup_dba"; private static final String strMySQLPassword = "123456"; private static Connection connection; public static Connection getConnection() { try {//from w ww. jav a 2s .c o m Class.forName(strDriver).newInstance(); connection = DriverManager.getConnection(strUrl, strMySQLUsername, strMySQLPassword); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return connection; } }