public class DBInfo extends quadbase.common.util.internal.DBInfoBasic implements IDatabaseInfo
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 :-
IDatabaseInfo
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
clone, equals, equals, equalsIgnoreQuery, getAdditionalDb, getContextFactory, getProviderURL, getTableNameFormat, isCloseConnectionEnabled, openConnection, read, readXML, setAdditionalDb, setTableNameFormat, toString, write, writeXML
@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)
url
- URL of database in form of jdbc:databaseName://machineName(or
IPaddress)/schemeNamedriver
- JDBC driver class name useusername
- login user namepassword
- login passwordquery
- SQL query to retrieve data from databaseapplet
- an applet or null if the program is an applicationpublic DBInfo(java.lang.String url, java.lang.String driver, java.lang.String username, java.lang.String password, java.lang.String query)
url
- URL of database in form of jdbc:databaseName://machineName(or
IPaddress)/schemeNamedriver
- JDBC driver class name usedusername
- login user namepassword
- login passwordquery
- SQL query to retrieve data from databasepublic 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)
url
- URL of database in form of jdbc:databaseName://machineName(or
IPaddress)/schemeNamedriver
- JDBC driver class name usedusername
- login user namepassword
- login passwordquery
- SQL query to retrieve data from databasepublic DBInfo(java.lang.String JNDIName, java.lang.String query, java.util.Hashtable<java.lang.String,java.lang.String> env)
JNDIName
- JNDI lookup name for the data basequery
- SQL query to retrieve data from data baseenv
- Environment properties for the initial context. Contains
INITIAL_CONTEXT_FACTORY and PROVIDER_URLpublic DBInfo(quadbase.common.util.IDatabaseInfo dbInfo)
dbInfo
- Creates a DBInfo object using information in dbInfo.@Deprecated public DBInfo(java.sql.Connection conn, java.lang.String query, java.applet.Applet applet)
conn
- a connection to the databasequery
- SQL query to retrieve data from databaseapplet
- the parent applet or null if called from applicationpublic DBInfo(java.sql.Connection conn, java.lang.String query)
conn
- a connection to the databasequery
- SQL query to retrieve data from databasepublic java.lang.String getURLString()
getURLString
in interface quadbase.common.util.IDatabaseInfo
getURLString
in class quadbase.common.util.internal.DBInfoBasic
public java.lang.String getDriverName()
getDriverName
in interface quadbase.common.util.IDatabaseInfo
getDriverName
in class quadbase.common.util.internal.DBInfoBasic
public java.lang.String getUserID()
getUserID
in interface quadbase.common.util.IDatabaseInfo
getUserID
in class quadbase.common.util.internal.DBInfoBasic
public java.lang.String getPassword()
getPassword
in interface quadbase.common.util.IDatabaseInfo
getPassword
in class quadbase.common.util.internal.DBInfoBasic
public java.lang.String getQuery()
getQuery
in interface quadbase.common.util.IDatabaseInfo
getQuery
in interface quadbase.common.util.IJNDIDatabaseInfo
getQuery
in class quadbase.common.util.internal.DBInfoBasic
public java.sql.Connection getConnection()
getConnection
in interface quadbase.common.util.IDatabaseInfo
getConnection
in interface quadbase.common.util.IJNDIDatabaseInfo
getConnection
in class quadbase.common.util.internal.DBInfoBasic
public java.lang.String getJNDIName()
getJNDIName
in interface quadbase.common.util.IJNDIDatabaseInfo
getJNDIName
in class quadbase.common.util.internal.DBInfoBasic
public boolean isUseJNDIDataSource()
isUseJNDIDataSource
in class quadbase.common.util.internal.DBInfoBasic
public java.util.Hashtable<java.lang.String,java.lang.String> getEnvProperties()
getEnvProperties
in interface quadbase.common.util.IJNDIDatabaseInfo
getEnvProperties
in class quadbase.common.util.internal.DBInfoBasic
public void setURLString(java.lang.String url)
setURLString
in class quadbase.common.util.internal.DBInfoBasic
public void setDriverName(java.lang.String driver)
setDriverName
in class quadbase.common.util.internal.DBInfoBasic
public void setUserID(java.lang.String username)
setUserID
in class quadbase.common.util.internal.DBInfoBasic
public void setPassword(java.lang.String password)
setPassword
in class quadbase.common.util.internal.DBInfoBasic
public void setQuery(java.lang.String query)
setQuery
in class quadbase.common.util.internal.DBInfoBasic
public void setJNDIName(java.lang.String name)
setJNDIName
in class quadbase.common.util.internal.DBInfoBasic
public void setUseJNDIDataSource(boolean b)
setUseJNDIDataSource
in class quadbase.common.util.internal.DBInfoBasic
public void setEnvProperties(java.util.Hashtable<java.lang.String,java.lang.String> env)
setEnvProperties
in class quadbase.common.util.internal.DBInfoBasic
public static java.sql.Connection getDatabaseConnection(java.lang.String driverName, java.lang.String urlString, java.lang.String userName, java.lang.String passwd)
driver
- The driver nameurlString
- The url to the databaseusername
- The username used to connect to the databasepassword
- The database passwordpublic static java.sql.Connection getDatabaseConnection(java.lang.String JNDIName, java.util.Hashtable<java.lang.String,java.lang.String> env) throws java.sql.SQLException
JNDIName
- JNDI lookup name for the databaseenv
- Environment properties for initial contextjava.sql.SQLException
public void setConnection(java.sql.Connection conn)
setConnection
in class quadbase.common.util.internal.DBInfoBasic
connection
- A reference to the Connection object.public boolean establishConnection()
establishConnection
in class quadbase.common.util.internal.DBInfoBasic
public void closeConnection()
closeConnection
in class quadbase.common.util.internal.DBInfoBasic
public DbData fetchData() throws java.sql.SQLException
java.sql.SQLException
public static quadbase.chart.ColData[] getColData(quadbase.common.util.IDatabaseInfo dbInfo, boolean isSpreadSheet, boolean[] transposeCol) throws java.lang.Exception
java.lang.Exception