Class DbSource

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

public class DbSource extends Object
This class describes a releational data source (URL, driver, user and password).
  • Field Details

  • Constructor Details

  • Method Details

    • getConnection

      public Connection getConnection() throws ClassNotFoundException, SQLException
      Get a JDBC connection to the db source.
      Returns:
      a JDBC connection
      Throws:
      ClassNotFoundException - if the JDBC driver couldn't be loaded
      SQLException - if the connection couldn't be created
    • switchProperties

      public ResourceProperties switchProperties(ResourceProperties newProps) throws 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:
      ClassNotFoundException - if jdbc driver class couldn't be found
    • getDriverName

      public String getDriverName()
      Return the class name of the JDBC driver
      Returns:
      the class name of the JDBC driver
    • getName

      public 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(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 Object
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object