001: /*
002: * (C) Copyright 2004 Nabh Information Systems, Inc.
003: *
004: * All copyright notices regarding Nabh's products MUST remain
005: * intact in the scripts and in the outputted HTML.
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package com.nabhinc.util.info;
023:
024: import java.sql.Connection;
025: import java.sql.DatabaseMetaData;
026:
027: import org.apache.commons.logging.Log;
028: import org.apache.commons.logging.LogFactory;
029:
030: import com.nabhinc.util.db.DBUtil;
031:
032: /**
033: *
034: *
035: * @author Padmanabh Dabke
036: * (c) 2004 Nabh Information Systems, Inc. All Rights Reserved.
037: */
038: public class DatabaseInfo {
039: private static Log log = LogFactory.getLog(DatabaseInfo.class);
040:
041: private String diProductName = null;
042: private String diProductVersion = null;
043: private String diUrl = null;
044: private String diUserName = null;
045: private String diDriverName = null;
046: private String diDriverVersion = null;
047: private int diMaxConnections = 0;
048:
049: private String diErrorMessage;
050:
051: public DatabaseInfo() {
052: Connection conn = null;
053: try {
054: conn = DBUtil.getConnection();
055: DatabaseMetaData dbMetaData = conn.getMetaData();
056: diUrl = dbMetaData.getURL();
057: diUserName = dbMetaData.getUserName();
058: diProductName = dbMetaData.getDatabaseProductName();
059: diProductVersion = dbMetaData.getDatabaseProductVersion();
060: diDriverName = dbMetaData.getDriverName();
061: diDriverVersion = dbMetaData.getDriverVersion();
062: diMaxConnections = dbMetaData.getMaxConnections();
063: } catch (Exception ex) {
064: log.error("Error in getting database parameter info.", ex);
065: diErrorMessage = ex.getMessage();
066: } finally {
067: DBUtil.close(conn);
068: }
069: }
070:
071: public String getProductName() {
072: return diProductName;
073: }
074:
075: public String getProductVersion() {
076: return diProductVersion;
077: }
078:
079: public String getURL() {
080: return diUrl;
081: }
082:
083: public String getUserName() {
084: return diUserName;
085: }
086:
087: public String getDriverName() {
088: return diDriverName;
089: }
090:
091: public String getDriverVersion() {
092: return diDriverVersion;
093: }
094:
095: public String getErrorMessage() {
096: return diErrorMessage;
097: }
098:
099: public int getMaxConcurrentConnections() {
100: return diMaxConnections;
101: }
102: }
|