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; public class Main { static final String DB_URL = "jdbc:mysql://localhost/pos"; static final String USER = "root"; static final String PASS = ""; static Connection connection = null; public static Connection getConnection() { try {// w ww . j a va 2 s . c om Class.forName("com.mysql.jdbc.Driver"); //STEP 3: Open a connection System.out.println("Connecting to database..."); connection = (Connection) DriverManager.getConnection(DB_URL, USER, PASS); } catch (Exception e) { System.out.println("Class path not found"); } return connection; } }