package mit.sql ;

public class SqlFactory
	extends sql.SqlFactory
{

	public sql.Connection newConnection
		( String databaseURL
		, String driverName
		, String username
		, String password
		, Object id
		)
		throws Exception
	{
		return
			mit.sql.Connection.create
				( databaseURL
				, driverName
				, username
				, password
				, id
				) ;
	}

	public sql.Connection newConnection
		( String database
		, String username
		, String password
		, Object id
		)
	throws Exception
	{
		return
			mit.sql.Connection.create
				( database
				, username
				, password
				, id
				) ;
	}

	public sql.Connection newConnection
		( java.util.Properties properties
		, Object id
		)
		throws Exception
	{
		sql.Connection connection = null ;
		if( null != properties )
		{
			String username = ( String ) properties.get( "Username" ) ;
			String password = ( String ) properties.get( "Password" ) ;
			if( null != properties.get( "databaseURL" ) )
			{
				String databaseURL = ( String ) properties.get( "databaseURL" ) ;
				String driverName = ( String ) properties.get( "driverName" ) ;
				connection
					= mit.sql.Connection.create
						( databaseURL
						, driverName
						, username
						, password
						, id
						) ;
			}
			else
			{
				String database = ( String ) properties.get( "Database" ) ;
				connection
					= mit.sql.Connection.create
						( database
						, username
						, password
						, id
						) ;
			}
		}
		return connection ;
	}

}
