Here you can find the source of GetConnection()
private static void GetConnection() throws Exception
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; public class Main { private static String dbConnectionStr = "jdbc:sqlserver://127.0.0.1:1433;databasename=cyyz"; private static String sUser = "sa"; private static String sPassWord = "Ss123"; private static String dbDriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; private static Connection dbConnection; private static void GetConnection() throws Exception { if (dbConnection == null) { Class.forName(dbDriverName); dbConnection = DriverManager.getConnection(dbConnectionStr, sUser, sPassWord); }//from ww w .j ava2s . c om } }