Here you can find the source of getConnection()
public static Connection getConnection() throws Exception
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DriverManager; public class Main { private static ThreadLocal<Connection> conns = new ThreadLocal<Connection>(); public static Connection getConnection() throws Exception { Connection conn = conns.get(); if (conn == null) { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/insurancemall"; conn = DriverManager.getConnection(url, "root", ""); conns.set(conn);/*from w ww . ja va 2 s.co m*/ } return conn; } }