## helma.objectmodel.db
Class DbSource

    java.lang.Object
      helma.objectmodel.db.DbSource

    public class DbSource

extends java.lang.Object

This class describes a releational data source (URL, driver, user and password).

Field Summary
`protected java.lang.String` `url`

Constructor Summary
`DbSource(java.lang.String name, ResourceProperties props)` Creates a new DbSource object.

Method Summary
`boolean` `equals(java.lang.Object obj)` Indicates whether some other object is "equal to" this one.
`java.sql.Connection` `getConnection()` Get a JDBC connection to the db source.
`protected DbMapping` `getDbMapping(java.lang.String tablename)` Look up a DbMapping instance for the given table name.
`java.lang.String` `getDriverName()` Return the class name of the JDBC driver
`java.lang.String` `getName()` Return the name of the db dource
`int` `hashCode()` Returns a hash code value for the object.
`boolean` `isH2()` Check if this DbSource represents a H2 database
`boolean` `isMySQL()` Check if this DbSource represents a MySQL database
`boolean` `isOracle()` Check if this DbSource represents an Oracle database
`boolean` `isPostgreSQL()` Check if this DbSource represents a PostgreSQL database
`protected void` `registerDbMapping(DbMapping dbmap)` Register a dbmapping by its table name.
`static void` `setDefaultProps(ResourceProperties props)` Set the default (server-wide) properties
`ResourceProperties` `switchProperties(ResourceProperties newProps)` Set the db properties to newProps, and return the old properties.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### url

    protected java.lang.String url

Constructor Detail

### DbSource

    public DbSource(java.lang.String name,
                    ResourceProperties props)
             throws java.lang.ClassNotFoundException

  Creates a new DbSource object.

  Parameters:
    `name` - the db source name
    `props` - the properties
  Throws:
    `java.lang.ClassNotFoundException` - if the JDBC driver couldn't be loaded

Method Detail

### getConnection

    public java.sql.Connection getConnection()
                                      throws java.lang.ClassNotFoundException,
                                             java.sql.SQLException

  Get a JDBC connection to the db source.

  Returns:
    a JDBC connection
  Throws:
    `java.lang.ClassNotFoundException` - if the JDBC driver couldn't be loaded
    `java.sql.SQLException` - if the connection couldn't be created

### switchProperties

    public ResourceProperties switchProperties(ResourceProperties newProps)
                                        throws java.lang.ClassNotFoundException

  Set the db properties to newProps, and return the old properties.

  Parameters:
    `newProps` - the new properties to use for this db source
  Returns:
    the old properties
  Throws:
    `java.lang.ClassNotFoundException` - if jdbc driver class couldn't be found

### getDriverName

    public java.lang.String getDriverName()

  Return the class name of the JDBC driver

  Returns:
    the class name of the JDBC driver

### getName

    public java.lang.String getName()

  Return the name of the db dource

  Returns:
    the name of the db dource

### setDefaultProps

    public static void setDefaultProps(ResourceProperties props)

  Set the default (server-wide) properties

  Parameters:
    `props` - server default db.properties

### isOracle

    public boolean isOracle()

  Check if this DbSource represents an Oracle database

  Returns:
    true if we're using an oracle JDBC driver

### isMySQL

    public boolean isMySQL()

  Check if this DbSource represents a MySQL database

  Returns:
    true if we're using a MySQL JDBC driver

### isPostgreSQL

    public boolean isPostgreSQL()

  Check if this DbSource represents a PostgreSQL database

  Returns:
    true if we're using a PostgreSQL JDBC driver

### isH2

    public boolean isH2()

  Check if this DbSource represents a H2 database

  Returns:
    true if we're using a H2 JDBC driver

### registerDbMapping

    protected void registerDbMapping(DbMapping dbmap)

  Register a dbmapping by its table name.

  Parameters:
    `dbmap` - the DbMapping instance to register

### getDbMapping

    protected DbMapping getDbMapping(java.lang.String tablename)

  Look up a DbMapping instance for the given table name.

  Parameters:
    `tablename` - the table name
  Returns:
    the matching DbMapping instance

### hashCode

    public int hashCode()

  Returns a hash code value for the object.

  Overrides:
    `hashCode` in class `java.lang.Object`

### equals

    public boolean equals(java.lang.Object obj)

  Indicates whether some other object is "equal to" this one.

  Overrides:
    `equals` in class `java.lang.Object`

Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.