Here you can find the source of getNewDatabaseConnection(String dbUser, String dbPassword)
public static Connection getNewDatabaseConnection(String dbUser, String dbPassword) throws SQLException
//package com.java2s; /*/*w w w.ja va 2 s . c om*/ * Copyright 2013-2015 Lakshmisha Bhat * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.sql.*; public class Main { public static final String DB_URL = "jdbc:sqlserver://zinc14.pha.jhu.edu:1433;Database=owsensordb"; private static final String COM_SQLSERVER_JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; public static Connection getNewDatabaseConnection(String dbUser, String dbPassword) throws SQLException { lookupDriver(); return connectAndUseDatabase(dbUser, dbPassword); } private static void lookupDriver() { try { Class.forName(COM_SQLSERVER_JDBC_DRIVER); } catch (ClassNotFoundException e) { throw new IllegalStateException( "Where is your MySQL JDBC Driver?", e); } } private static Connection connectAndUseDatabase(String dbUser, String dbPassword) throws SQLException { return DriverManager.getConnection(DB_URL, dbUser, dbPassword); } }