java.lang.Object
cloud.piranha.database.environment.EnvironmentDriver
All Implemented Interfaces:
java.sql.Driver

public class EnvironmentDriver
extends java.lang.Object
implements java.sql.Driver
A JDBC driver that looks for environment variables to delegate to a another JDBC driver.

E.g. if you set the JDBC url in your application to be jdbc:environment:0 it will look for environment variables of the format:

    PIRANHA_ENVIRONMENT.0.URL=
    PIRANHA_ENVIRONMENT.0.PROPERTY.1=name=value
    PIRANHA_ENVIRONMENT.0.PROPERTY.2=name2=value2
 
Author:
Manfred Riem (mriem@manorrock.com)
  • Constructor Summary

    Constructors
    Constructor Description
    EnvironmentDriver()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    boolean acceptsURL​(java.lang.String url)
    De we accept the URL?
    java.sql.Connection connect​(java.lang.String url, java.util.Properties info)
    Connect to the database.
    int getMajorVersion()
    Get the major version.
    int getMinorVersion()
    Get the minor version.
    java.util.logging.Logger getParentLogger()
    Get the parent logger.
    java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties info)
    Get the property information.
    boolean jdbcCompliant()
    Are we JDBC compliant.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EnvironmentDriver

      public EnvironmentDriver()
      Constructor.
  • Method Details

    • connect

      public java.sql.Connection connect​(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
      Connect to the database.
      Specified by:
      connect in interface java.sql.Driver
      Parameters:
      url - the URL.
      info - the connection properties.
      Returns:
      the connection
      Throws:
      java.sql.SQLException - when a SQL error occurs.
      See Also:
      Driver.connect(java.lang.String, java.util.Properties)
    • acceptsURL

      public boolean acceptsURL​(java.lang.String url) throws java.sql.SQLException
      De we accept the URL?
      Specified by:
      acceptsURL in interface java.sql.Driver
      Returns:
      true if we do, false otherwise.
      Throws:
      java.sql.SQLException
      See Also:
      Driver.acceptsURL(java.lang.String)
    • getPropertyInfo

      public java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
      Get the property information.
      Specified by:
      getPropertyInfo in interface java.sql.Driver
      Parameters:
      url - the URL.
      info - the properties
      Returns:
      the list of property information.
      Throws:
      java.sql.SQLException
      See Also:
      Driver.getPropertyInfo(java.lang.String, java.util.Properties)
    • getMajorVersion

      public int getMajorVersion()
      Get the major version.
      Specified by:
      getMajorVersion in interface java.sql.Driver
      Returns:
      1.
    • getMinorVersion

      public int getMinorVersion()
      Get the minor version.
      Specified by:
      getMinorVersion in interface java.sql.Driver
      Returns:
      0.
    • jdbcCompliant

      public boolean jdbcCompliant()
      Are we JDBC compliant.
      Specified by:
      jdbcCompliant in interface java.sql.Driver
      Returns:
      true.
    • getParentLogger

      public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
      Get the parent logger.
      Specified by:
      getParentLogger in interface java.sql.Driver
      Returns:
      the parent logger.
      Throws:
      java.sql.SQLFeatureNotSupportedException
      See Also:
      Driver.getParentLogger()