Here you can find the source of getConnection()
public static Connection getConnection()
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { private static Connection connection = null; public static Connection getConnection() { if (connection != null) return connection; try {//from w ww . j a va 2 s.c om Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { //System.out.println("Where is your Oracle JDBC Driver?"); e.printStackTrace(); return null; } //System.out.println("Oracle JDBC Driver Registered!"); try { connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "dbms", "dbms"); } catch (SQLException e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); return null; } if (connection != null) { System.out.println("You made it, take control your database now!"); } else { System.out.println("Failed to make connection!"); } return connection; } }