KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > persist > db > DatabaseImpl


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: DatabaseImpl.java,v 1.35 2007/01/07 06:14:18 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.persist.db;
23
24 import java.sql.Connection JavaDoc;
25 import java.sql.ResultSet JavaDoc;
26 import java.sql.SQLException JavaDoc;
27 import java.util.logging.Level JavaDoc;
28 import java.util.logging.Logger JavaDoc;
29
30 import org.opensubsystems.core.error.OSSConfigException;
31 import org.opensubsystems.core.error.OSSDatabaseAccessException;
32 import org.opensubsystems.core.error.OSSException;
33 import org.opensubsystems.core.persist.db.db2.DB2DatabaseImpl;
34 import org.opensubsystems.core.persist.db.hsqldb.HsqlDBDatabaseImpl;
35 import org.opensubsystems.core.persist.db.maxdb.MaxDBDatabaseImpl;
36 import org.opensubsystems.core.persist.db.mssql.MSSQLDatabaseImpl;
37 import org.opensubsystems.core.persist.db.mysql.MySQLDatabaseImpl;
38 import org.opensubsystems.core.persist.db.oracle.OracleDatabaseImpl;
39 import org.opensubsystems.core.persist.db.postgresql.PostgreSQLDatabaseImpl;
40 import org.opensubsystems.core.persist.db.sapdb.SapDBDatabaseImpl;
41 import org.opensubsystems.core.persist.db.sybase.SybaseDatabaseImpl;
42 import org.opensubsystems.core.util.GlobalConstants;
43 import org.opensubsystems.core.util.Log;
44
45 /**
46  * Base class for all classes encapsulating various differences in
47  * behaviour for different database.
48  *
49  * Most likely one project will use only one database therefore this class
50  * contains factory methods to instantiate and return default instance of
51  * database even though it still allows multiple instances of database to exist
52  * since all attributes are non-static.
53  *
54  * @version $Id: DatabaseImpl.java,v 1.35 2007/01/07 06:14:18 bastafidli Exp $
55  * @author Miro Halas
56  * @code.reviewer Miro Halas
57  * @code.reviewed 1.28 2005/10/10 09:00:32 bastafidli
58  */

59 public abstract class DatabaseImpl implements Database
60 {
61    // Constants ////////////////////////////////////////////////////////////////
62

63    /**
64     * Number specifying maximal safe length for members within the IN () clause
65     * Because there is limitation for sql statement length (in sap db is default
66     * 64 kb) and in() expression can contain lot of members.
67     */

68    public static final int MAX_SAFE_LENGTH = 1000;
69
70    /**
71     * Lock used in synchronization blocks.
72     */

73    private static final String JavaDoc DATABASEIMPL_LOCK = "DATABASEIMPL_LOCK";
74
75    /**
76     * String used to identify HSQLDB JDBC driver
77     */

78    private static final String JavaDoc HSQLDB_DRIVER_IDENTIFIER = ".hsqldb.";
79
80    /**
81     * String used to identify SAP JDBC driver
82     */

83    private static final String JavaDoc SAPDB_DRIVER_IDENTIFIER = ".sap.";
84    
85    /**
86     * String used to identify MaxDB JDBC driver
87     */

88    private static final String JavaDoc MAXDB_DRIVER_IDENTIFIER = ".maxdb.";
89
90    /**
91     * String used to identify PostgreSQL JDBC driver
92     */

93    private static final String JavaDoc POSTGRESQL_DRIVER_IDENTIFIER = ".postgresql.";
94
95    /**
96     * String used to identify MySQL JDBC driver
97     */

98    private static final String JavaDoc MYSQL_DRIVER_IDENTIFIER = ".mysql.";
99
100    /**
101     * String used to identify original Microsoft MS SQL Server JDBC driver and also
102     * internal BEA Weblogic driver
103     */

104    private static final String JavaDoc MSSQL_DRIVER_IDENTIFIER = ".sqlserver.";
105
106    /**
107     * String used to identify IBM DB2 JDBC driver
108     */

109    private static final String JavaDoc DB2_DRIVER_IDENTIFIER = ".db2.";
110
111    /**
112     * String used to identify Sybase JDBC driver
113     */

114    private static final String JavaDoc SYBASE_DRIVER_IDENTIFIER = ".sybase.";
115
116    /**
117     * String used to identify Oracle JDBC driver
118     */

119    private static final String JavaDoc ORACLE_DRIVER_IDENTIFIER = "oracle.";
120
121    /**
122     * String used to identify Oracle JDBC driver.
123     * Used by WebLogic.
124     */

125    private static final String JavaDoc ORACLE_OCI_DRIVER_IDENTIFIER = ".oci.";
126
127    /**
128     * Default string used to identify MS SQL Server and Sybase JDBC driver.
129     * Used by open source jTDS.
130     */

131    private static final String JavaDoc JTDS_DRIVER_IDENTIFIER = ".jtds.";
132
133    /**
134     * Default string used to identify MS SQL Server JDBC driver.
135     * Used by I-NET.
136     */

137    private static final String JavaDoc INET_DRIVER_IDENTIFIER = ".inet.";
138
139    /**
140     * Default string used to identify MS SQL Server JDBC driver.
141     * Used by J-NETDirect.
142     */

143    private static final String JavaDoc JNETDIRECT_DRIVER_IDENTIFIER = ".jnetdirect.";
144
145    /**
146     * String used to identify MS SQL Server from the URL
147     */

148    private static final String JavaDoc MSSQL_URL_IDENTIFIER = ":sqlserver:";
149    
150    /**
151     * String used to identify Sybase from the URL
152     */

153    private static final String JavaDoc SYBASE_URL_IDENTIFIER = ":sybase:";
154
155    // Cached values ////////////////////////////////////////////////////////////
156

157    /**
158     * Logger for this class
159     */

160    private static Logger JavaDoc s_logger = Log.getInstance(DatabaseImpl.class);
161
162    /**
163     * Reference to the default database.
164     */

165    private static Database s_dbDefaultDatabase = null;
166    
167    // Attributes ///////////////////////////////////////////////////////////////
168

169    /**
170     * Flag signaling that the database schema was initialized;
171     */

172    protected boolean m_bDatabaseSchemaInitialized;
173    
174    /**
175     * Flag signaling that the database start is in progress.
176     */

177    protected boolean m_bDatabaseStartInProgress;
178    
179    /**
180     * Flag if database was started.
181     */

182    protected boolean m_bDatabaseStarted;
183    
184    /**
185     * Database schema for this database. By default it is versioned database
186     * schema which manages all other schemas in the database.
187     */

188    protected VersionedDatabaseSchema m_vdsSchema;
189
190    // Constructors /////////////////////////////////////////////////////////////
191

192    /**
193     * Default constructor. Protected so that default database cannot be
194     * constructed explicitely.
195     *
196     * @throws OSSException - problem creating connection factory
197     */

198    protected DatabaseImpl(
199    ) throws OSSException
200    {
201       // We cannot initialize schema here because we would have circular dependency
202
// so wait and initialize it when it is needed
203
m_vdsSchema = null;
204       m_bDatabaseSchemaInitialized = false;
205       m_bDatabaseStartInProgress = false;
206       m_bDatabaseStarted = false;
207    }
208
209    // Factory methods //////////////////////////////////////////////////////////
210

211    /**
212     * Get the default database instance.
213     *
214     * @return Database
215     * @throws OSSException - problem accessing the database
216     */

217    public static Database getInstance(
218    ) throws OSSException
219    {
220       if (s_dbDefaultDatabase == null)
221       {
222          // Only if the defautl database wasn't set by other means, create a new one
223
// Synchronize just for the creation
224
synchronized (DATABASEIMPL_LOCK)
225          {
226             // This database has unknown schema
227
if (s_dbDefaultDatabase == null)
228             {
229                String JavaDoc strDriver;
230                String JavaDoc strURL;
231                DatabaseConnectionFactory dcfFactory;
232                
233                try
234                {
235                   dcfFactory = DatabaseConnectionFactoryImpl.getInstance();
236                }
237                catch (OSSDatabaseAccessException bfeExc)
238                {
239                   throw new OSSDatabaseAccessException("Cannot create connection factory.",
240                                                           bfeExc);
241                }
242                strDriver = dcfFactory.getRealDatabaseDriver();
243                strURL = dcfFactory.getDatabaseURL();
244                if (strDriver == null || strURL == null)
245                {
246                   // Maybe the driver wasn't loaded yet so load the default
247
// properties and try again
248
dcfFactory.loadDefaultDatabaseProperties();
249                   strDriver = dcfFactory.getRealDatabaseDriver();
250                   strURL = dcfFactory.getDatabaseURL();
251                }
252                if (strDriver != null)
253                {
254                   strDriver = strDriver.toLowerCase();
255                   // TODO: Improve: Determine dynamically what databases are
256
// supported for now it can be set programmatically using
257
// setInstance
258
if (strDriver.indexOf(HSQLDB_DRIVER_IDENTIFIER) != -1)
259                   {
260                      setInstance(new HsqlDBDatabaseImpl());
261                   }
262                   else if (strDriver.indexOf(SAPDB_DRIVER_IDENTIFIER) != -1)
263                   {
264                      setInstance(new SapDBDatabaseImpl());
265                   }
266                   else if (strDriver.indexOf(MAXDB_DRIVER_IDENTIFIER) != -1)
267                   {
268                      setInstance(new MaxDBDatabaseImpl());
269                   }
270                   else if (strDriver.indexOf(POSTGRESQL_DRIVER_IDENTIFIER) != -1)
271                   {
272                      setInstance(new PostgreSQLDatabaseImpl());
273                   }
274                   else if (strDriver.indexOf(MYSQL_DRIVER_IDENTIFIER) != -1)
275                   {
276                      setInstance(new MySQLDatabaseImpl());
277                   }
278                   else if (strDriver.indexOf(MSSQL_DRIVER_IDENTIFIER) != -1
279                            || strDriver.indexOf(INET_DRIVER_IDENTIFIER) != -1
280                            || strDriver.indexOf(JNETDIRECT_DRIVER_IDENTIFIER) != -1)
281                   {
282                      setInstance(new MSSQLDatabaseImpl());
283                   }
284                   else if (strDriver.indexOf(DB2_DRIVER_IDENTIFIER) != -1)
285                   {
286                      setInstance(new DB2DatabaseImpl());
287                   }
288                   else if (strDriver.indexOf(SYBASE_DRIVER_IDENTIFIER) != -1)
289                   {
290                      setInstance(new SybaseDatabaseImpl());
291                   }
292                   else if (strDriver.indexOf(ORACLE_DRIVER_IDENTIFIER) != -1
293                            || strDriver.indexOf(ORACLE_OCI_DRIVER_IDENTIFIER) != -1)
294                   {
295                      setInstance(new OracleDatabaseImpl());
296                   }
297                   else if (strDriver.indexOf(JTDS_DRIVER_IDENTIFIER) != -1)
298                   {
299                      if (strURL.indexOf(MSSQL_URL_IDENTIFIER) != -1)
300                      {
301                         setInstance(new MSSQLDatabaseImpl());
302                      }
303                      else if (strURL.indexOf(SYBASE_URL_IDENTIFIER) != -1)
304                      {
305                         setInstance(new SybaseDatabaseImpl());
306                      }
307                      else
308                      {
309                         throw new OSSConfigException("Unsupported URL '" + strURL +
310                                                      "' for JDBC driver: " + strDriver);
311                      }
312                   }
313                   else
314                   {
315                      throw new OSSConfigException("Unsupported JDBC driver: " + strDriver);
316                   }
317                }
318                else
319                {
320                   throw new OSSConfigException("Cannot determine what JDBC driver to use.");
321                }
322             }
323          }
324       }
325       
326       return s_dbDefaultDatabase;
327    }
328    
329    /**
330     * Get the default database instance if it was started otherwise return null.
331     *
332     * @return Database - null if it wasn't started otherwise instance of the database
333     * @throws OSSException - problem accessing the database
334     */

335    public static Database getInstanceIfStarted(
336    ) throws OSSException
337    {
338       return ((s_dbDefaultDatabase != null) && (s_dbDefaultDatabase.isStarted()))
339              ? s_dbDefaultDatabase : null;
340    }
341    
342    /**
343     * Set default database instance. This instance will be returned by
344     * getInstance method until reset.
345     *
346     * @param dbDatabase - new default database instance
347     * @see #getInstance
348     */

349    public static void setInstance(
350       Database dbDatabase
351    )
352    {
353       if (GlobalConstants.ERROR_CHECKING)
354       {
355          assert dbDatabase != null : "Default database instance cannot be null";
356       }
357       
358       synchronized (DATABASEIMPL_LOCK)
359       {
360          s_dbDefaultDatabase = dbDatabase;
361          s_logger.fine("Default database is "
362                        + s_dbDefaultDatabase.getClass().getName());
363       }
364    }
365
366    // Database administration //////////////////////////////////////////////////
367

368    /**
369     * {@inheritDoc}
370     */

371    public void start(
372    ) throws OSSException
373    {
374 // Log.getLogger().entering(this.getClass().getName(), "start");
375

376       try
377       {
378          if ((!m_bDatabaseStarted) || (!m_bDatabaseSchemaInitialized))
379          {
380             m_bDatabaseStartInProgress = true;
381             
382             Connection JavaDoc cntDBConnection = null;
383    
384             try
385             {
386                try
387                {
388                   startDatabaseServer();
389                }
390                catch (OSSException bfeExc)
391                {
392                   s_logger.log(Level.WARNING,
393                                      "Cannot start database server, trying to create.",
394                                      bfeExc);
395                   try
396                   {
397                      createDatabaseInstance();
398                   }
399                   catch (OSSException bfeExc1)
400                   {
401                      s_logger.log(Level.SEVERE,
402                                          "Error while creating database instance.",
403                                          bfeExc1);
404                   }
405                }
406                // Request connection as normal user. If the database doesn't exist
407
// or it wasn't initialized (e.g. user doesn't exists) this will fail
408
try
409                {
410                   // Request autocommit false since we might be modifying database
411
cntDBConnection
412                      = DatabaseConnectionFactoryImpl.getInstance().requestConnection(false);
413                }
414                catch (OSSDatabaseAccessException dceExc)
415                {
416                   Connection JavaDoc cntAdminDBConnection = null;
417                   
418                   // We couldn't connect to database by default. It might mean, that
419
// the user and or database doesn't exists
420

421                   try
422                   {
423                      // Try to create the database
424
// HSQL will create the database if we try to connect as administrator
425
// Request autocommit false since we are modifying database
426
cntAdminDBConnection = getAdminConnection(false);
427       
428                      s_logger.log(Level.FINER,
429                                          "Database exists or was just created.");
430       
431                      // Use the existing administrator connection to create user
432
createUser(cntAdminDBConnection);
433                   }
434                   finally
435                   {
436                      // We have created our own connection therefore we need to return it
437
DatabaseConnectionFactoryImpl.getInstance().returnConnection(
438                         cntAdminDBConnection);
439                   }
440
441                   // Some connections pools (PROXOOL) have problems if when the
442
// first time we request connections the user doesn't exist
443
// and they cannot recover from it. Just in case the current
444
// connection pool is one of those, restart it at this time
445
// since the user was created above
446
DatabaseConnectionFactoryImpl.getInstance().stop();
447                   // Once the connection pool is stopped, it should restart
448
// automatically when connection is requested again
449

450                   // Now I should be able to get connection to database as
451
// given user since we want to create everything as that user
452
// Request autocommit false since we might be modifying database
453
cntDBConnection
454                      = DatabaseConnectionFactoryImpl.getInstance().requestConnection(false);
455                   if (cntDBConnection == null)
456                   {
457                      throw new OSSDatabaseAccessException("Cannot get connection to database" +
458                                                          " after user was created.");
459                   }
460                }
461
462                // Now initialize the schema, this will create all tables,
463
// stored procedures and indexes
464
if (m_vdsSchema != null)
465                {
466                   m_vdsSchema.init(cntDBConnection,
467                      DatabaseConnectionFactoryImpl.getInstance().getDatabaseUser());
468                }
469    
470                // At this point we don't know if this is just a single operation
471
// and we need to commit or if it is a part of bigger transaction
472
// and the commit is not desired until all operations proceed.
473
// Therefore let the DatabaseTransactionFactory resolve it
474
DatabaseTransactionFactoryImpl.getInstance().commitTransaction(cntDBConnection);
475
476                m_bDatabaseSchemaInitialized = true;
477                s_logger.log(Level.FINER, "Database is initialized.");
478             }
479             catch (Throwable JavaDoc thr)
480             {
481                s_logger.log(Level.SEVERE, "Failed to initialize database.",
482                                    thr);
483                if (cntDBConnection != null)
484                {
485                   try
486                   {
487                      // At this point we don't know if this is just a single operation
488
// and we need to commit or if it is a part of bigger transaction
489
// and the commit is not desired until all operations proceed.
490
// Therefore let the DatabaseTransactionFactory resolve it
491
DatabaseTransactionFactoryImpl.getInstance().rollbackTransaction(
492                                                              cntDBConnection);
493                   }
494                   catch (SQLException JavaDoc sqleExc)
495                   {
496                      // Ignore this
497
s_logger.log(Level.WARNING,
498                                          "Failed to rollback changes for creation of database.",
499                                          sqleExc);
500                   }
501                }
502                throw new OSSDatabaseAccessException("Failed to initialize database.",
503                                                    thr);
504             }
505             finally
506             {
507                DatabaseConnectionFactoryImpl.getInstance().returnConnection(
508                   cntDBConnection);
509                m_bDatabaseStartInProgress = false;
510             }
511             m_bDatabaseStarted = true;
512          }
513       }
514       finally
515       {
516 // Log.getLogger().exiting(this.getClass().getName(), "start");
517
}
518    }
519
520    /**
521     * {@inheritDoc}
522     */

523    public void stop(
524    ) throws OSSException
525    {
526       // Stop any transaction factory
527
DatabaseTransactionFactoryImpl.getInstance().stop();
528       // Stop any connection factory
529
DatabaseConnectionFactoryImpl.getInstance().stop();
530       m_vdsSchema = (VersionedDatabaseSchema) DatabaseSchemaManager.getInstance(
531                        VersionedDatabaseSchema.class);
532       m_bDatabaseStarted = false;
533    }
534
535    /**
536     * {@inheritDoc}
537     */

538    public boolean isStarted(
539    )
540    {
541       return m_bDatabaseStarted;
542    }
543
544    /**
545     * Method for starting database instance.
546     * For HSQL it is not needed because the database is started (created)
547     * when the administrator is connected to. For HSQL will be empty
548     * implementation of this method. For SAPDB is neccessary to start
549     * DB instance before connecting to.
550     *
551     * @throws OSSException - problem starting the server
552     */

553    public abstract void startDatabaseServer(
554    ) throws OSSException;
555
556    /**
557     * Method for creating database instance.
558     * For HSQL it is not needed because the database is created
559     * when the administrator is connected to. For HSQL will be empty
560     * implementation of this method. For SAPDB is neccessary to create
561     * DB instance before connecting to.
562     *
563     * @throws OSSException - problem creating the database instance
564     */

565    public abstract void createDatabaseInstance(
566    ) throws OSSException;
567
568    // Schema management methods ////////////////////////////////////////////////
569

570    /**
571     * {@inheritDoc}
572     */

573    public void add(
574       DatabaseSchema dsSchema
575    ) throws OSSException
576    {
577       if (GlobalConstants.ERROR_CHECKING)
578       {
579          assert dsSchema != null : "Cannot add null schema.";
580       }
581       
582       if (m_vdsSchema == null)
583       {
584          m_vdsSchema = (VersionedDatabaseSchema)DatabaseSchemaManager.getInstance(
585                                                    VersionedDatabaseSchema.class);
586       }
587       m_vdsSchema.add(dsSchema);
588
589       m_bDatabaseSchemaInitialized = false;
590
591       // We have new schema, it needs to be reinitialized
592
s_logger.log(Level.FINEST, "Database schema " + dsSchema.getName()
593                           + " added to the database versioned schema.");
594    }
595
596    /**
597     * {@inheritDoc}
598     */

599    public void add(
600       Class JavaDoc clsSchema
601    ) throws OSSException
602    {
603       add(DatabaseSchemaManager.getInstance(clsSchema));
604    }
605
606    /**
607     * {@inheritDoc}
608     */

609    public String JavaDoc getConnectionTestStatement()
610    {
611       // This table is very static, doesn't change and it is small so this
612
// query should be super fast
613
return "select count(*) from " + VersionedDatabaseSchema.SCHEMA_TABLE_NAME;
614    }
615    
616    /**
617     * {@inheritDoc}
618     */

619    public int getTransactionIsolation(
620       int iTransactionIsolation
621    )
622    {
623       // By default database should support all so provide simple default
624
// implemenation
625
return iTransactionIsolation;
626    }
627
628    /**
629     * {@inheritDoc}
630     */

631    public int getSelectListResultSetType(
632    )
633    {
634       // HSQLDB requires the statement to be ResultSet.TYPE_SCROLL_INSENSITIVE
635
// and ResultSet.CONCUR_READ_ONLY to be able call last, etc. so lets
636
// assume that is the default behaviour for all databases for now
637
return ResultSet.TYPE_SCROLL_INSENSITIVE;
638    }
639    
640    /**
641     * {@inheritDoc}
642     */

643    public boolean hasAbsolutePositioningSupport(
644    )
645    {
646       // By default lets assume that database supports it so that not every
647
// implementation has to implement this method and if it doesn't supports
648
// it then it will override this.
649
return true;
650    }
651
652    /**
653     * {@inheritDoc}
654     */

655    public boolean preferCountToLast(
656    )
657    {
658       // By default if we support absolute positioning then use it
659
return (!hasAbsolutePositioningSupport());
660    }
661
662    /**
663     * {@inheritDoc}
664     */

665    public boolean hasSelectListRangeSupport(
666    )
667    {
668       // By default return value which indicates that database has no special
669
// support to return limitation of how many rows to return
670
return false;
671    }
672
673    /**
674     * {@inheritDoc}
675     */

676    public int getSelectListResultSetConcurrency(
677    )
678    {
679       // HSQL requires the statement to be ResultSet.TYPE_SCROLL_INSENSITIVE
680
// and ResultSet.CONCUR_READ_ONLY to be able call last, etc. so lets
681
// assume that is the default behaviour for all databases for now
682
return ResultSet.CONCUR_READ_ONLY;
683    }
684    
685    // Helper methods ///////////////////////////////////////////////////////////
686

687    /**
688     * Create database user which will be used by connection pool to access
689     * the database.
690     *
691     * @param cntAdminDBConnection - connection with rights to create users
692     * @throws OSSException - cannot create user
693     */

694    protected abstract void createUser(
695       Connection JavaDoc cntAdminDBConnection
696    ) throws OSSException;
697       
698    /**
699     * Get connection with administration priviledges.
700     *
701     * @param bAutoCommit - desired autocommit setting for the connection
702     * @return Connection - connection with administrator priviledges, never null
703     * @throws OSSException - problem connecting to database
704     */

705    protected Connection JavaDoc getAdminConnection(
706       boolean bAutoCommit
707    ) throws OSSException
708    {
709       Connection JavaDoc cntAdminDBConnection;
710       DatabaseConnectionFactory connectionFactory;
711       
712       connectionFactory = DatabaseConnectionFactoryImpl.getInstance();
713       
714       // HSQLDB will create the database if we try to connect as administrator
715
if (connectionFactory.getUseAdminDataSource())
716       {
717          if (!connectionFactory.isDataSourceDefined(
718                 DatabaseConnectionFactoryImpl.ADMIN_DATASOURCE_NAME))
719          {
720             // The datasource for administration connection is not yet defined
721
// so lets define it
722
connectionFactory.addDataSource(
723                DatabaseConnectionFactoryImpl.ADMIN_DATASOURCE_NAME,
724                connectionFactory.getDatabaseDriver(),
725                connectionFactory.getDatabaseURL(),
726                connectionFactory.getDatabaseAdminUser(),
727                connectionFactory.getDatabaseAdminPassword());
728          }
729          
730          // We were asked to get the administration connection using separate
731
// datasource rather then using separate creadentials. This is due
732
// to the fact that some J2EE application servers such as WebLogic 9.1
733
// do not propagate the credentials to the database driver
734
cntAdminDBConnection = connectionFactory.requestConnection(
735                                     bAutoCommit,
736                                     DatabaseConnectionFactoryImpl.ADMIN_DATASOURCE_NAME);
737       }
738       else
739       {
740          cntAdminDBConnection = connectionFactory.requestConnection(
741                                     bAutoCommit,
742                                     connectionFactory.getDatabaseAdminUser(),
743                                     connectionFactory.getDatabaseAdminPassword());
744       }
745       
746       return cntAdminDBConnection;
747    }
748 }
749
Popular Tags