Java JDBC SQLServer Connection GetConnection()

Here you can find the source of GetConnection()

Description

Get Connection

License

Apache License

Declaration

private static void GetConnection() throws Exception 

Method Source Code


//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
    }
}

Related

  1. getConnection()
  2. getConnection()