EspressReport 6.6

quadbase.ChartAPI
Class DBInfo

java.lang.Object
  extended by quadbase.common.util.internal.DBInfoBasic
      extended by quadbase.ChartAPI.DBInfo
All Implemented Interfaces:
quadbase.common.util.IDatabaseInfo, quadbase.common.util.IJNDIDatabaseInfo
Direct Known Subclasses:
SimpleQueryFileInfo

public class DBInfo
extends quadbase.common.util.internal.DBInfoBasic
implements IDatabaseInfo

DBInfo

This class provides an implementation for the @link quadbase.util.IDatabaseInfo interface. It stores information necessary to retrieve data from a database.

An example of a DBInfo object is :-

    DBInfo databaseInfo = new DBInfo(new DBInfo("jdbc:odbc:woodview",
      "sun.jdbc.odbc.JdbcOdbcDriver",
      "userName",
      "passWord",
    "select * from sales");

See Also:
IDatabaseInfo

Field Summary
 
Fields inherited from class quadbase.common.util.internal.DBInfoBasic
additionalDb, connection, doNotCloseConnection, driver, env, info, JNDIName, query, tableNameFormat, url, useJNDIDataSource, XMLTAG
 
Fields inherited from interface quadbase.common.util.IDatabaseInfo
DB_DRIVER_ACCESS, DB_DRIVER_DB2, DB_DRIVER_HSQL, DB_DRIVER_INFORMIX, DB_DRIVER_JTDS, DB_DRIVER_MSSSQL, DB_DRIVER_MYSQL, DB_DRIVER_ORACLE, DB_DRIVER_POINTBASE, DB_DRIVER_POSTGRESQL
 
Constructor Summary
DBInfo(java.sql.Connection conn, java.lang.String query)
          Creates a new instance of DBInfo using the given Connection object.
DBInfo(java.sql.Connection conn, java.lang.String query, java.applet.Applet applet)
          Deprecated.  
DBInfo(quadbase.common.util.IDatabaseInfo dbInfo)
          Creates a new instance of DBInfo.
DBInfo(java.lang.String JNDIName, java.lang.String query, java.util.Hashtable<java.lang.String,java.lang.String> env)
          Creates a new instance of DBInfo.
DBInfo(java.lang.String url, java.lang.String driver, java.lang.String username, java.lang.String password, java.lang.String query)
          Creates a new instance of DbInfo.
DBInfo(java.lang.String url, java.lang.String driver, java.lang.String username, java.lang.String password, java.lang.String query, java.applet.Applet applet)
          Deprecated.  
DBInfo(java.lang.String url, java.lang.String driver, java.lang.String username, java.lang.String password, java.lang.String query, java.util.Vector<java.lang.String> additionalDb)
          Creates a new instance of DbInfo.
 
Method Summary
 void closeConnection()
          This function closes the connection to the database.
 boolean establishConnection()
          This function establishes a connection to the database specified by the URL string.
 DbData fetchData()
          Gets the data from database, return as instance of DbData.
static quadbase.chart.ColData[] getColData(quadbase.common.util.IDatabaseInfo dbInfo, boolean isSpreadSheet, boolean[] transposeCol)
           
 java.sql.Connection getConnection()
          Gets the connection object, if one exists.
static java.sql.Connection getDatabaseConnection(java.lang.String JNDIName, java.util.Hashtable<java.lang.String,java.lang.String> env)
          This static function establishes a connection to the specified database and returns a connection object to it.
static java.sql.Connection getDatabaseConnection(java.lang.String driverName, java.lang.String urlString, java.lang.String userName, java.lang.String passwd)
          This static function establishes a connection to the specified database and returns a connection object to it.
 java.lang.String getDriverName()
          Gets the JDBC driver name.
 java.util.Hashtable<java.lang.String,java.lang.String> getEnvProperties()
          Gets environment properties for initial context.
 java.lang.String getJNDIName()
          Gets the JNDI lookup name of the data base.
 java.lang.String getPassword()
          Gets the password
 java.lang.String getQuery()
          Gets the SQL query
 java.lang.String getURLString()
          Gets the URL of database.
 java.lang.String getUserID()
          Gets the user name.
 boolean isUseJNDIDataSource()
          Returns if the DBInfo uses JNDI DataSource.
 void setConnection(java.sql.Connection conn)
          This function sets the connection field in this object.
 void setDriverName(java.lang.String driver)
          Sets the JDBC driver name.
 void setEnvProperties(java.util.Hashtable<java.lang.String,java.lang.String> env)
          Sets environment properties for initial context.
 void setJNDIName(java.lang.String name)
          Sets the JNDI lookup name.
 void setPassword(java.lang.String password)
          Sets the password.
 void setQuery(java.lang.String query)
          Sets the SQL query.
 void setURLString(java.lang.String url)
          Sets the URL of database.
 void setUseJNDIDataSource(boolean b)
          Sets if use JNDI DataSource.
 void setUserID(java.lang.String username)
          Sets the user name.
 
Methods inherited from class quadbase.common.util.internal.DBInfoBasic
clone, equals, equals, equalsIgnoreQuery, getAdditionalDb, getContextFactory, getProviderURL, getTableNameFormat, isCloseConnectionEnabled, openConnection, read, readXML, setAdditionalDb, setTableNameFormat, toString, write, writeXML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DBInfo

@Deprecated
public DBInfo(java.lang.String url,
                         java.lang.String driver,
                         java.lang.String username,
                         java.lang.String password,
                         java.lang.String query,
                         java.applet.Applet applet)
Deprecated. 

Creates a new instance of DbInfo.

Parameters:
url - URL of database in form of jdbc:databaseName://machineName(or IPaddress)/schemeName
driver - JDBC driver class name use
username - login user name
password - login password
query - SQL query to retrieve data from database
applet - an applet or null if the program is an application

DBInfo

public DBInfo(java.lang.String url,
              java.lang.String driver,
              java.lang.String username,
              java.lang.String password,
              java.lang.String query)
Creates a new instance of DbInfo.

Parameters:
url - URL of database in form of jdbc:databaseName://machineName(or IPaddress)/schemeName
driver - JDBC driver class name used
username - login user name
password - login password
query - SQL query to retrieve data from database

DBInfo

public DBInfo(java.lang.String url,
              java.lang.String driver,
              java.lang.String username,
              java.lang.String password,
              java.lang.String query,
              java.util.Vector<java.lang.String> additionalDb)
Creates a new instance of DbInfo.

Parameters:
url - URL of database in form of jdbc:databaseName://machineName(or IPaddress)/schemeName
driver - JDBC driver class name used
username - login user name
password - login password
query - SQL query to retrieve data from database

DBInfo

public DBInfo(java.lang.String JNDIName,
              java.lang.String query,
              java.util.Hashtable<java.lang.String,java.lang.String> env)
Creates a new instance of DBInfo.

Parameters:
JNDIName - JNDI lookup name for the data base
query - SQL query to retrieve data from data base
env - Environment properties for the initial context.  Contains INITIAL_CONTEXT_FACTORY and PROVIDER_URL

DBInfo

public DBInfo(quadbase.common.util.IDatabaseInfo dbInfo)
Creates a new instance of DBInfo.

Parameters:
dbInfo - Creates a DBInfo object using information in dbInfo.

DBInfo

@Deprecated
public DBInfo(java.sql.Connection conn,
                         java.lang.String query,
                         java.applet.Applet applet)
Deprecated. 

Creates a new instance of DBInfo using the given Connection object.

Parameters:
conn - a connection to the database
query - SQL query to retrieve data from database
applet - the parent applet or null if called from application

DBInfo

public DBInfo(java.sql.Connection conn,
              java.lang.String query)
Creates a new instance of DBInfo using the given Connection object.

Parameters:
conn - a connection to the database
query - SQL query to retrieve data from database
Method Detail

getURLString

public java.lang.String getURLString()
Gets the URL of database.

Specified by:
getURLString in interface quadbase.common.util.IDatabaseInfo
Overrides:
getURLString in class quadbase.common.util.internal.DBInfoBasic

getDriverName

public java.lang.String getDriverName()
Gets the JDBC driver name.

Specified by:
getDriverName in interface quadbase.common.util.IDatabaseInfo
Overrides:
getDriverName in class quadbase.common.util.internal.DBInfoBasic

getUserID

public java.lang.String getUserID()
Gets the user name.

Specified by:
getUserID in interface quadbase.common.util.IDatabaseInfo
Overrides:
getUserID in class quadbase.common.util.internal.DBInfoBasic

getPassword

public java.lang.String getPassword()
Gets the password

Specified by:
getPassword in interface quadbase.common.util.IDatabaseInfo
Overrides:
getPassword in class quadbase.common.util.internal.DBInfoBasic

getQuery

public java.lang.String getQuery()
Gets the SQL query

Specified by:
getQuery in interface quadbase.common.util.IDatabaseInfo
Specified by:
getQuery in interface quadbase.common.util.IJNDIDatabaseInfo
Overrides:
getQuery in class quadbase.common.util.internal.DBInfoBasic

getConnection

public java.sql.Connection getConnection()
Gets the connection object, if one exists.

Specified by:
getConnection in interface quadbase.common.util.IDatabaseInfo
Specified by:
getConnection in interface quadbase.common.util.IJNDIDatabaseInfo
Overrides:
getConnection in class quadbase.common.util.internal.DBInfoBasic

getJNDIName

public java.lang.String getJNDIName()
Gets the JNDI lookup name of the data base.

Specified by:
getJNDIName in interface quadbase.common.util.IJNDIDatabaseInfo
Overrides:
getJNDIName in class quadbase.common.util.internal.DBInfoBasic

isUseJNDIDataSource

public boolean isUseJNDIDataSource()
Returns if the DBInfo uses JNDI DataSource.

Overrides:
isUseJNDIDataSource in class quadbase.common.util.internal.DBInfoBasic

getEnvProperties

public java.util.Hashtable<java.lang.String,java.lang.String> getEnvProperties()
Gets environment properties for initial context.

Specified by:
getEnvProperties in interface quadbase.common.util.IJNDIDatabaseInfo
Overrides:
getEnvProperties in class quadbase.common.util.internal.DBInfoBasic

setURLString

public void setURLString(java.lang.String url)
Sets the URL of database.

Overrides:
setURLString in class quadbase.common.util.internal.DBInfoBasic

setDriverName

public void setDriverName(java.lang.String driver)
Sets the JDBC driver name.

Overrides:
setDriverName in class quadbase.common.util.internal.DBInfoBasic

setUserID

public void setUserID(java.lang.String username)
Sets the user name.

Overrides:
setUserID in class quadbase.common.util.internal.DBInfoBasic

setPassword

public void setPassword(java.lang.String password)
Sets the password.

Overrides:
setPassword in class quadbase.common.util.internal.DBInfoBasic

setQuery

public void setQuery(java.lang.String query)
Sets the SQL query.

Overrides:
setQuery in class quadbase.common.util.internal.DBInfoBasic

setJNDIName

public void setJNDIName(java.lang.String name)
Sets the JNDI lookup name.

Overrides:
setJNDIName in class quadbase.common.util.internal.DBInfoBasic

setUseJNDIDataSource

public void setUseJNDIDataSource(boolean b)
Sets if use JNDI DataSource.

Overrides:
setUseJNDIDataSource in class quadbase.common.util.internal.DBInfoBasic

setEnvProperties

public void setEnvProperties(java.util.Hashtable<java.lang.String,java.lang.String> env)
Sets environment properties for initial context.

Overrides:
setEnvProperties in class quadbase.common.util.internal.DBInfoBasic

getDatabaseConnection

public static java.sql.Connection getDatabaseConnection(java.lang.String driverName,
                                                        java.lang.String urlString,
                                                        java.lang.String userName,
                                                        java.lang.String passwd)
This static function establishes a connection to the specified database and returns a connection object to it.

Parameters:
driver - The driver name
urlString - The url to the database
username - The username used to connect to the database
password - The database password
Returns:
connection The connection object

getDatabaseConnection

public static java.sql.Connection getDatabaseConnection(java.lang.String JNDIName,
                                                        java.util.Hashtable<java.lang.String,java.lang.String> env)
                                                 throws java.sql.SQLException
This static function establishes a connection to the specified database and returns a connection object to it.

Parameters:
JNDIName - JNDI lookup name for the database
env - Environment properties for initial context
Returns:
connection The connection object
Throws:
java.sql.SQLException

setConnection

public void setConnection(java.sql.Connection conn)
This function sets the connection field in this object.

Overrides:
setConnection in class quadbase.common.util.internal.DBInfoBasic
Parameters:
connection - A reference to the Connection object.

establishConnection

public boolean establishConnection()
This function establishes a connection to the database specified by the URL string.

Overrides:
establishConnection in class quadbase.common.util.internal.DBInfoBasic
Returns:
true if connection is established, false otherwise

closeConnection

public void closeConnection()
This function closes the connection to the database.

Overrides:
closeConnection in class quadbase.common.util.internal.DBInfoBasic

fetchData

public DbData fetchData()
                 throws java.sql.SQLException
Gets the data from database, return as instance of DbData. ClassNotFoundException is thrown if JDBC driver not found. If there is error in SQL execution an SQLException will throw.

Throws:
java.sql.SQLException

getColData

public static quadbase.chart.ColData[] getColData(quadbase.common.util.IDatabaseInfo dbInfo,
                                                  boolean isSpreadSheet,
                                                  boolean[] transposeCol)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

EspressReport 6.6