func (dbc *Connection) Open() error {
	// bail if we've already opened the connection.
	if dbc.Connection != nil {
		return Error(ErrConnectionAlreadyOpen)
	}
	if dbc.Config.IsZero() {
		return Error(ErrConfigUnset)
	}
	if dbc.BufferPool == nil {
		dbc.BufferPool = bufferutil.NewPool(dbc.Config.BufferPoolSizeOrDefault())
	}

	dsn := dbc.Config.CreateDSN()
	namedValues, err := ParseURL(dsn)
	if err != nil {
		return err
	}

	// open the connection
	dbConn, err := sql.Open(dbc.Config.EngineOrDefault(), namedValues)
	if err != nil {
		return Error(err)
	}

	dbc.Connection = dbConn
	dbc.Connection.SetConnMaxLifetime(dbc.Config.MaxLifetimeOrDefault())
	dbc.Connection.SetConnMaxIdleTime(dbc.Config.MaxIdleTimeOrDefault())
	dbc.Connection.SetMaxIdleConns(dbc.Config.IdleConnectionsOrDefault())
	dbc.Connection.SetMaxOpenConns(dbc.Config.MaxConnectionsOrDefault())
	return nil
}
// Open returns a connection object, either a cached connection object or creating a new one in the process.
Open returns a connection object, either a cached connection object or creating a new one in the process.
// Open returns a connection object either a cached connection object or creating a new one in the process .
func (dbc *Connection) Open() error {
	if dbc.Connection != nil {
		return Error(ErrConnectionAlreadyOpen)
	}
	if dbc.Config.IsZero() {
		return Error(ErrConfigUnset)
	}
	if dbc.BufferPool == nil {
		dbc.BufferPool = bufferutil.NewPool(dbc.Config.BufferPoolSizeOrDefault())
	}
	dsn := dbc.Config.CreateDSN()
	namedValues, err := ParseURL(dsn)
	if err != nil {
		return err
	}
	dbConn, err := sql.Open(dbc.Config.EngineOrDefault(), namedValues)
	if err != nil {
		return Error(err)
	}
	dbc.Connection = dbConn
	dbc.Connection.SetConnMaxLifetime(dbc.Config.MaxLifetimeOrDefault())
	dbc.Connection.SetConnMaxIdleTime(dbc.Config.MaxIdleTimeOrDefault())
	dbc.Connection.SetMaxIdleConns(dbc.Config.IdleConnectionsOrDefault())
	dbc.Connection.SetMaxOpenConns(dbc.Config.MaxConnectionsOrDefault())
	return nil
}
func ( dbc * Connection ) Open ( ) error { if dbc . Connection != nil { return Error ( ErrConnectionAlreadyOpen ) } if dbc . Config . IsZero ( ) { return Error ( ErrConfigUnset ) } if dbc . BufferPool == nil { dbc . BufferPool = bufferutil . NewPool ( dbc . Config . BufferPoolSizeOrDefault ( ) ) } dsn := dbc . Config . CreateDSN ( ) namedValues , err := ParseURL ( dsn ) if err != nil { return err } dbConn , err := sql . Open ( dbc . Config . EngineOrDefault ( ) , namedValues ) if err != nil { return Error ( err ) } dbc . Connection = dbConn dbc . Connection . SetConnMaxLifetime ( dbc . Config . MaxLifetimeOrDefault ( ) ) dbc . Connection . SetConnMaxIdleTime ( dbc . Config . MaxIdleTimeOrDefault ( ) ) dbc . Connection . SetMaxIdleConns ( dbc . Config . IdleConnectionsOrDefault ( ) ) dbc . Connection . SetMaxOpenConns ( dbc . Config . MaxConnectionsOrDefault ( ) ) return nil }
Open returns a connection object, either a cached connection object or creating a new one in the process.
Open returns a connection object either a cached connection object or creating a new one in the process .
// bail if we've already opened the connection. // open the connection