/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DriverManagerConnection.java	1.12 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.common;

import com.sun.cts.util.*;
import com.sun.cts.harness.*;
import java.sql.*;
import java.util.*;

public class DriverManagerConnection extends ServiceEETest 
implements JDBCTestConnectionManager {

  public Connection getConnection(Properties p) throws ClassNotFoundException, SQLException, Exception{
    Connection con = null;
    String dbName, dbUser, dbPassword, dbDriver;
    dbName = dbUser = dbPassword = dbDriver = null;

    dbName = p.getProperty("db1","");
    dbUser = p.getProperty("user1","");
    dbPassword = p.getProperty("password1","");
    dbDriver = p.getProperty("Driver","");

    TestUtil.logTrace("Database1 : " + dbName);
    TestUtil.logTrace("Username  : " + dbUser);
    TestUtil.logTrace("Password  : " + dbPassword);
    TestUtil.logTrace("Driver    : " + dbDriver);

    TestUtil.logTrace("About to load the driver class");
    Class.forName(dbDriver);
    TestUtil.logMsg("Successfully loaded the driver class");

    TestUtil.logTrace("About to make the DB connection");
    con=DriverManager.getConnection(dbName, dbUser, dbPassword);
    TestUtil.logMsg("Made the JDBC connection to the DB");

    return con;
  }

}
