|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjimm.datavision.source.DataSource
jimm.datavision.source.sql.Database
public class Database
A database knows about the tables in a database.
| Field Summary | |
|---|---|
protected java.sql.Connection |
conn
|
protected boolean |
connectionOwnedByMe
|
protected java.lang.String |
connInfo
|
protected static java.lang.String[] |
DB_OBJECT_TYPES
|
protected java.lang.String |
driverClassName
|
protected boolean |
hasPassword
|
protected java.lang.String |
name
|
protected java.lang.String |
quoteString
|
protected java.lang.String |
schemaName
|
protected boolean |
storesLowerCaseIdentifiers
|
protected boolean |
storesUpperCaseIdentifiers
|
protected java.util.HashMap |
tableCacheMap
|
protected java.util.TreeMap |
tables
|
protected java.lang.String |
username
|
| Fields inherited from class jimm.datavision.source.DataSource |
|---|
metadataURL, query, report |
| Constructor Summary | |
|---|---|
|
Database(java.sql.Connection conn,
Report report)
|
|
Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user)
Constructor. |
|
Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user,
java.lang.String password)
Constructor. |
protected |
Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user,
java.lang.String password,
boolean givenPassword)
Constructor. |
| Method Summary | |
|---|---|
boolean |
areRecordsSelectable()
Used to enable/disable the "Select Records" menu item. |
boolean |
areRecordsSortable()
Used to enable/disable the "Sort By" menu item. |
boolean |
canGroupRecords()
Used to enable/disable the "Group By" menu item. |
boolean |
canJoinTables()
Used to enable/disable the "Table Linker" menu item. |
java.util.Iterator |
columns()
Returns an iterator over all columns. |
protected void |
doWriteXML(XMLWriter out)
Writes this database and all its tables as an XML tag. |
DataCursor |
execute()
|
Column |
findColumn(java.lang.Object id)
Given an id (a column name), returns the column that has that id. |
protected Table |
findTable(java.lang.String tableName)
Given a table name, find the table. |
protected Table |
findTableWithId(java.lang.String id)
Finds table with given id string. |
java.sql.Connection |
getConnection()
Returns a connection to the database. |
java.lang.String |
getConnectionInfo()
Returns the connection info string. |
java.lang.String |
getDriverClassName()
Returns the driver class name. |
java.lang.String |
getName()
Returns the database name. |
java.lang.String |
getPassword()
Returns the password. |
java.lang.String |
getUserName()
Returns the user name. |
void |
initializeConnection()
Initializes the connection to the database. |
boolean |
isConnectionEditable()
Used to enable/disable the "Connection" menu item. |
boolean |
isSQLGenerated()
Used to enable/disable the "SQL Query Text" menu item. |
protected void |
loadAllTables()
Loads information about all tables in the database. |
protected void |
loadTablesUsingSchemaNameAndTypes(java.sql.DatabaseMetaData dbmd,
java.lang.String schema,
java.lang.String[] objectTypes)
Loads our list of tables using a database meta data object and a schema name. |
java.lang.String |
quoteString()
|
void |
reset(java.lang.String driverClassName,
java.lang.String connInfo,
java.lang.String dbName,
java.lang.String username,
java.lang.String password)
Reset key instance variables, closes current connection, and "reloads" all table information (compares new info with existing info and complains if any existing info is not in the new info). |
protected void |
setConnectionInfo(java.lang.String newConnectionInfo)
Sets the connection info string. |
protected void |
setDriverClassName(java.lang.String newDriverClassName)
Sets the driver class name. |
protected void |
setName(java.lang.String newName)
Sets the name. |
void |
setPassword(java.lang.String newPassword)
Sets the password. |
void |
setUserName(java.lang.String newUserName)
Sets the user name. |
boolean |
storesLowerCaseIdentifiers()
|
boolean |
storesUpperCaseIdentifiers()
|
java.util.Iterator |
tables()
Returns an iterator over all tables, or null if the
data source does not have tables (for example, a character-separated
file data source). |
java.util.Iterator |
tablesUsedInReport()
Returns an iterator over all tables actually used in the report, or null if the data source does not have tables (for example,
a character-separated file data source). |
| Methods inherited from class jimm.datavision.source.DataSource |
|---|
addColumn, alreadyUsedSourceFile, canRunReports, columnsInTablesUsedInReport, containsReferenceTo, getQuery, getReport, getSourceFile, indexOfSelectable, needsSourceFile, readMetadataFrom, reloadColumns, removeSort, reuseSourceFile, setSourceFile, usesSourceFile, writeXML |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String[] DB_OBJECT_TYPES
protected java.lang.String driverClassName
protected java.lang.String connInfo
protected java.lang.String name
protected java.lang.String username
protected java.util.TreeMap tables
protected java.util.HashMap tableCacheMap
protected java.lang.String schemaName
protected java.sql.Connection conn
protected boolean hasPassword
protected boolean connectionOwnedByMe
protected boolean storesLowerCaseIdentifiers
protected boolean storesUpperCaseIdentifiers
protected java.lang.String quoteString
| Constructor Detail |
|---|
public Database(java.sql.Connection conn,
Report report)
throws java.sql.SQLException
java.sql.SQLException
public Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user)
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
UserCancellationException
driverClassName - database driver class nameconnInfo - database connection info stringreport - the report using this databasename - the database nameuser - the user name to use when logging in to the database
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
UserCancellationException
public Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
UserCancellationException
driverClassName - database driver class nameconnInfo - database connection info stringreport - the report using this databasename - the database nameuser - the user name to use when logging in to the databasepassword - the database password
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
UserCancellationException
protected Database(java.lang.String driverClassName,
java.lang.String connInfo,
Report report,
java.lang.String name,
java.lang.String user,
java.lang.String password,
boolean givenPassword)
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
UserCancellationException
driverClassName - database driver class nameconnInfo - database connection info stringreport - the report using this databasename - the database nameuser - the user name to use when logging in to the databasepassword - the database passwordgivenPassword - if true, the password was passed in
to some other constructor
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
UserCancellationException| Method Detail |
|---|
public boolean canJoinTables()
DataSource
canJoinTables in class DataSourcetrue if the "Table Linker" menu item
should be enabled.public boolean isSQLGenerated()
DataSource
isSQLGenerated in class DataSourcetrue if the "SQL Query Text" menu item
should be enabled.public boolean isConnectionEditable()
DataSource
isConnectionEditable in class DataSourcetrue if the "Connection" menu item
should be enabled.public boolean areRecordsSelectable()
DataSource
areRecordsSelectable in class DataSourcetrue if the "Select Records" menu item
should be enabled.public boolean areRecordsSortable()
DataSource
areRecordsSortable in class DataSourcetrue if the "Sort By" menu item
should be enabled.public boolean canGroupRecords()
DataSource
canGroupRecords in class DataSourcetrue if the "Group By" menu item
should be enabled.public Column findColumn(java.lang.Object id)
null. Uses
Table.findColumn.
findColumn in class DataSourceid - a column id
null if no column with the specified
id existsTable.findColumn(java.lang.Object)protected Table findTable(java.lang.String tableName)
tableName - a table name, perhaps including a schema name.protected Table findTableWithId(java.lang.String id)
null if
it is not found. If the report says that database names are not
case-sensitive, then we do a case-insensitive comparison.
id - a table id; if names are not case-sensitive then id
will be lower-case when it is passed inpublic java.util.Iterator tables()
DataSourcenull if the
data source does not have tables (for example, a character-separated
file data source).
tables in class DataSourcenull iterator over all tablespublic java.util.Iterator tablesUsedInReport()
DataSourcenull if the data source does not have tables (for example,
a character-separated file data source).
tablesUsedInReport in class DataSourcenull iterator over all tables used
in the reportpublic java.util.Iterator columns()
DataSource
columns in class DataSource
public DataCursor execute()
throws java.sql.SQLException
execute in class DataSourcejava.sql.SQLExceptionpublic boolean storesLowerCaseIdentifiers()
public boolean storesUpperCaseIdentifiers()
public java.lang.String quoteString()
public void initializeConnection()
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
UserCancellationException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
UserCancellationExceptionpublic java.sql.Connection getConnection()
public void reset(java.lang.String driverClassName,
java.lang.String connInfo,
java.lang.String dbName,
java.lang.String username,
java.lang.String password)
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
UserCancellationException
Note: if the connection we currently have was created by this object, we close it. If the connection was handed to us, we do not close the connection.
driverClassName - database driver class nameconnInfo - database connection info stringdbName - database nameusername - the user name to use when logging in to the database
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
UserCancellationException
protected void loadAllTables()
throws java.sql.SQLException
null schema name.
java.sql.SQLException
protected void loadTablesUsingSchemaNameAndTypes(java.sql.DatabaseMetaData dbmd,
java.lang.String schema,
java.lang.String[] objectTypes)
throws java.sql.SQLException
null.
dbmd - the database meta data objectobjectTypes - a list of database object typesschema - the schema name; may be null
java.sql.SQLExceptionpublic java.lang.String getDriverClassName()
protected void setDriverClassName(java.lang.String newDriverClassName)
newDriverClassName - the driver class namepublic java.lang.String getConnectionInfo()
protected void setConnectionInfo(java.lang.String newConnectionInfo)
newConnectionInfo - the connection info stringpublic java.lang.String getName()
protected void setName(java.lang.String newName)
newName - the new namepublic java.lang.String getUserName()
public void setUserName(java.lang.String newUserName)
newUserName - the new user namepublic java.lang.String getPassword()
public void setPassword(java.lang.String newPassword)
newPassword - the new passwordprotected void doWriteXML(XMLWriter out)
doWriteXML in class DataSourceout - a writer that knows how to write XML
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||