LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute
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.
CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
NAME
Bio::EnsEMBL::DBSQL::ProxyDBConnection - Database connection wrapper allowing for one backing connection to be used for multiple DBs
SYNOPSIS
my $dbc = Bio::EnsEMBL::DBSQL::DBConnection->new(-HOST => 'host', -PORT => 3306, -USER => 'user');
my $p_h_dbc = Bio::EnsEMBL::DBSQL::ProxyDBConnection->new(-DBC => $dbc, -DBNAME => 'human');
my $p_m_dbc = Bio::EnsEMBL::DBSQL::ProxyDBConnection->new(-DBC => $dbc, -DBNAME => 'mouse');
# With a 10 minute timeout reconnection in milliseconds
my $p_h_rc_dbc = Bio::EnsEMBL::DBSQL::ProxyDBConnection->new(-DBC => $dbc, -DBNAME => 'human', -RECONNECT_INTERVAL => (10*60*1000));
DESCRIPTION
This class is used to maintain one active connection to a database whilst it appears to be working against multiple schemas. It does this by checking the currently connected database before performing any query which could require a database change such as prepare.
This class is only intended for internal use so please do not use unless you are aware of what it will do and what the consequences of its usage are.
METHODS
switch_database
Description : Performs a switch of the backing DBConnection if the currently
connected database is not the same as the database this proxy
wants to connect to. It currently supports MySQL, Oracle and
Postges switches is untested with all bar MySQL. If it
cannot do a live DB/schema switch then it will disconnect
the connection and then wait for the next process to
connect therefore switching the DB.
Exceptions : None but will warn if you attempt to switch a DB with
active kids attached to the proxied database handle.
check_reconnection
Description : Looks to see if the last time we used the backing DBI
connection was greater than the reconnect_interval()
provided at construction or runtime. If enought time has
elapsed then a reconnection is attempted. We do not
attempt a reconnection if:
- No reconnect_interval was set
- The connection was not active
Exceptions : None apart from those raised from the reconnect() method
from DBConnection
reconnect_interval
Arg[1] : Integer reconnection interval in milliseconds
Description : Accessor for the reconnection interval expressed in milliseconds
Returntype : Int miliseconds for a reconnection interval
dbname
Arg[1] : String DB name
Description : Accessor for the name of the database we should use whenever
a DBConnection request is made via this class
Returntype : String the name of the database which we should use
Exceptions : None