butler.sql.metadata
Class Database

java.lang.Object
  extended by butler.util.BaseGroovyObjectSupport
      extended by butler.sql.metadata.Database
All Implemented Interfaces:
groovy.lang.GroovyObject

public class Database
extends butler.util.BaseGroovyObjectSupport

Representing a relational database. Normally a database instance. A database corrensponds to a jdbc data source. Database is a container class for database catalogs.

Author:
Fredrik Bertilsson

Constructor Summary
Database(java.lang.String alias)
          Constructs a database, with a given alias.
 
Method Summary
 void addCatalog(java.lang.String alias, Catalog cat)
           
 void addCatalogAlias(java.lang.String alias, java.lang.String name)
          Adds a catalog alias.
 boolean equals(Database other)
           
 java.lang.String getAlias()
          Returns the alias for this database.
 Catalog getCatalog(java.lang.String name)
          Returns the specified catalog.
 java.util.Iterator getCatalogNames()
           
 java.util.Map getCatalogs()
           
 java.sql.Connection getConnection()
           
 javax.sql.DataSource getDataSource()
          Returns the JDBC data source for this database.
 Catalog getDefaultCatalog()
          Returns the default catalog.
 Schema getDefaultSchema()
           
 SQLHelper getHelper()
           
 java.sql.DatabaseMetaData getMetaData()
           
 java.lang.Object getProperty(java.lang.String property)
           
 java.lang.String getQuote()
           
 java.lang.String getTypeName(int type)
           
 int hashCode()
           
 void loadCatalogs()
           
 void setDataSource(javax.sql.DataSource ds)
          Assigns the JDBC data source for this datbase.
 void setDefaultCatalog(Catalog cat)
           
 void setHelper(SQLHelper helper)
           
 void setQuote(java.lang.String quote)
           
 void setXADataSource(javax.sql.XADataSource xads)
           
 void toXML(org.xml.sax.ContentHandler handler)
           
 
Methods inherited from class butler.util.BaseGroovyObjectSupport
getMetaClass, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database(java.lang.String alias)
         throws java.lang.Exception
Constructs a database, with a given alias. This constructor should only be called by DatabaseBroker subclasses.

Throws:
java.lang.Exception
Method Detail

getAlias

public java.lang.String getAlias()
Returns the alias for this database.


getCatalog

public Catalog getCatalog(java.lang.String name)
                   throws java.lang.Exception
Returns the specified catalog.

Throws:
java.lang.Exception

addCatalog

public void addCatalog(java.lang.String alias,
                       Catalog cat)

getProperty

public java.lang.Object getProperty(java.lang.String property)
Specified by:
getProperty in interface groovy.lang.GroovyObject
Overrides:
getProperty in class butler.util.BaseGroovyObjectSupport

getCatalogs

public java.util.Map getCatalogs()

getDefaultCatalog

public Catalog getDefaultCatalog()
                          throws java.lang.Exception
Returns the default catalog.

Throws:
java.lang.Exception

setDefaultCatalog

public void setDefaultCatalog(Catalog cat)

getDefaultSchema

public Schema getDefaultSchema()
                        throws java.lang.Exception
Throws:
java.lang.Exception

addCatalogAlias

public void addCatalogAlias(java.lang.String alias,
                            java.lang.String name)
                     throws java.lang.Exception
Adds a catalog alias. This means that the catalog specified by the parameter name will also be available to retrive by the getCatalog() method with the alias name.

Throws:
java.lang.Exception

getDataSource

public javax.sql.DataSource getDataSource()
                                   throws java.lang.Exception
Returns the JDBC data source for this database.

Throws:
java.lang.Exception

setDataSource

public void setDataSource(javax.sql.DataSource ds)
                   throws java.lang.Exception
Assigns the JDBC data source for this datbase.

Throws:
java.lang.Exception

setXADataSource

public void setXADataSource(javax.sql.XADataSource xads)

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

equals

public boolean equals(Database other)

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

getHelper

public SQLHelper getHelper()
                    throws java.lang.Exception
Throws:
java.lang.Exception

setHelper

public void setHelper(SQLHelper helper)

getQuote

public java.lang.String getQuote()
                          throws java.lang.Exception
Throws:
java.lang.Exception

setQuote

public void setQuote(java.lang.String quote)

getTypeName

public java.lang.String getTypeName(int type)
                             throws java.lang.Exception
Throws:
java.lang.Exception

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toXML

public void toXML(org.xml.sax.ContentHandler handler)
           throws java.lang.Exception
Throws:
java.lang.Exception

loadCatalogs

public void loadCatalogs()
                  throws java.lang.Exception
Throws:
java.lang.Exception

getCatalogNames

public java.util.Iterator getCatalogNames()
                                   throws java.lang.Exception
Throws:
java.lang.Exception