Here you can find the source of getConnection()
public static Connection getConnection() throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { static String ip = "127.0.0.1"; static int port = 3306; static String database = "db_abbey"; static String encoding = "UTF-8"; static String loginName = "root"; static String password = "698970s"; public static Connection getConnection() throws SQLException { String url = String.format("jdbc:mysql://%s:%d/%s?characterEncoding=%s", ip, port, database, encoding); return DriverManager.getConnection(url, loginName, password); }//from w w w . jav a 2s . com }