Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.jdeveloper.db.adapter
Class AbstractConnectionCreator

java.lang.Object
  extended by oracle.jdeveloper.db.adapter.AbstractConnectionCreator
All Implemented Interfaces:
ConnectionCreator
Direct Known Subclasses:
AbstractOracleConnCreator, CustomConnectionCreator, DB2ConnectionCreator, MySQLConnectionCreator, ODBCConnectionCreator, SQLServerConnectionCreator

public abstract class AbstractConnectionCreator
extends java.lang.Object
implements ConnectionCreator

Abstract implementation of ConnectionCreator that implements getConnection() and creates a connection given the URL and driver class returned by getConnectionURL() and getDriverClassName().


Constructor Summary
AbstractConnectionCreator()
           
 
Method Summary
protected  boolean allowNullPassword()
          Returns false by default.
protected  java.util.ResourceBundle getBundle()
           
 java.sql.Connection getConnection(java.util.Properties props)
          Creates a Connection from the given Properties.
 java.lang.String getConnectionURL(java.util.Properties props)
          The default implementation on this abstract class return the DatabaseProvider.DRIVER_CLASS_REFTYPE property.
 java.lang.String getDriverClassName(java.util.Properties props)
          The default implementation on this class returns the DatabaseProvider.CUSTOM_URL_CLASS_REFTYPE property.
protected  java.lang.String getPropertyOrThrow(java.util.Properties props, java.lang.String name)
          Utility method to retrieve a property from the given Properties and throw an exception is the property is missing or empty.
protected  boolean hasLength(java.lang.String s)
          Utility method to check a string isn't null or empty.
 java.util.Collection<java.lang.String> listAllowedProperties()
          Gets a list of the properties that are relevant to this creator.
protected  void setCustomProperties(java.util.Properties connProps, java.util.Properties jdbcProps)
          Override to include connection type specific properties in the jdbc properties set that the driver will be created with.
 boolean shouldEncrypt(java.lang.String propName)
          By default only the password ( DatabaseProvider.PASSWORD_CLASS_REFTYPE ) is encrypted.
 boolean shouldPromptForPassword(java.util.Properties props)
          By default the password is prompted for if the password is null and save for password is set to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnectionCreator

public AbstractConnectionCreator()
Method Detail

getBundle

protected java.util.ResourceBundle getBundle()

shouldEncrypt

public boolean shouldEncrypt(java.lang.String propName)
By default only the password ( DatabaseProvider.PASSWORD_CLASS_REFTYPE ) is encrypted.

Specified by:
shouldEncrypt in interface ConnectionCreator
Returns:
true if the given property should not be stored as plain text

shouldPromptForPassword

public boolean shouldPromptForPassword(java.util.Properties props)
By default the password is prompted for if the password is null and save for password is set to true.

Specified by:
shouldPromptForPassword in interface ConnectionCreator
Parameters:
props - the connection details that might need a password prompted for
Returns:
whether to show the prompter

setCustomProperties

protected void setCustomProperties(java.util.Properties connProps,
                                   java.util.Properties jdbcProps)
Override to include connection type specific properties in the jdbc properties set that the driver will be created with.

Username, password and role are done by default by this abstract creator.

Parameters:
connProps - the connection properties defined in the connection definition.
jdbcProps - the properties that will be used to create the JDBC connection

getConnection

public java.sql.Connection getConnection(java.util.Properties props)
                                  throws java.sql.SQLException
Description copied from interface: ConnectionCreator
Creates a Connection from the given Properties. The Properties contains key/value pairs for the information required to create the connection.

Specified by:
getConnection in interface ConnectionCreator
Parameters:
props - the Properties containing the connection data
Returns:
a JDBC Connection to a database
Throws:
java.sql.SQLException - if the connection cannot be created because the data is wrong or the database is down.

allowNullPassword

protected boolean allowNullPassword()
Returns false by default. If overridden will allow a null password to be accepted for a connection.


hasLength

protected boolean hasLength(java.lang.String s)
Utility method to check a string isn't null or empty.


getPropertyOrThrow

protected java.lang.String getPropertyOrThrow(java.util.Properties props,
                                              java.lang.String name)
                                       throws java.sql.SQLException
Utility method to retrieve a property from the given Properties and throw an exception is the property is missing or empty.

Throws:
java.sql.SQLException

getConnectionURL

public java.lang.String getConnectionURL(java.util.Properties props)
                                  throws java.sql.SQLException
The default implementation on this abstract class return the DatabaseProvider.DRIVER_CLASS_REFTYPE property. Override as appropriate.

Specified by:
getConnectionURL in interface ConnectionCreator
Throws:
java.sql.SQLException

getDriverClassName

public java.lang.String getDriverClassName(java.util.Properties props)
                                    throws java.sql.SQLException
The default implementation on this class returns the DatabaseProvider.CUSTOM_URL_CLASS_REFTYPE property. Override as appropraite.

Specified by:
getDriverClassName in interface ConnectionCreator
Throws:
java.sql.SQLException

listAllowedProperties

public java.util.Collection<java.lang.String> listAllowedProperties()
Description copied from interface: ConnectionCreator
Gets a list of the properties that are relevant to this creator. If a property is not listed, it is not needed/supported.

Specified by:
listAllowedProperties in interface ConnectionCreator
Returns:
a list of the allowed property keys for the connection's properties.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.