Class EnvironmentDriver
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 booleanacceptsURL(java.lang.String url)De we accept the URL?java.sql.Connectionconnect(java.lang.String url, java.util.Properties info)Connect to the database.intgetMajorVersion()Get the major version.intgetMinorVersion()Get the minor version.java.util.logging.LoggergetParentLogger()Get the parent logger.java.sql.DriverPropertyInfo[]getPropertyInfo(java.lang.String url, java.util.Properties info)Get the property information.booleanjdbcCompliant()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.SQLExceptionConnect to the database.- Specified by:
connectin interfacejava.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.SQLExceptionDe we accept the URL?- Specified by:
acceptsURLin interfacejava.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.SQLExceptionGet the property information.- Specified by:
getPropertyInfoin interfacejava.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:
getMajorVersionin interfacejava.sql.Driver- Returns:
- 1.
-
getMinorVersion
public int getMinorVersion()Get the minor version.- Specified by:
getMinorVersionin interfacejava.sql.Driver- Returns:
- 0.
-
jdbcCompliant
public boolean jdbcCompliant()Are we JDBC compliant.- Specified by:
jdbcCompliantin interfacejava.sql.Driver- Returns:
- true.
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedExceptionGet the parent logger.- Specified by:
getParentLoggerin interfacejava.sql.Driver- Returns:
- the parent logger.
- Throws:
java.sql.SQLFeatureNotSupportedException- See Also:
Driver.getParentLogger()
-