Package org.apache.spark.sql.jdbc
Class JdbcConnectionProvider
Object
org.apache.spark.sql.jdbc.JdbcConnectionProvider
::DeveloperApi::
Connection provider which opens connection toward various databases (database specific instance
needed). If any authentication required then it's the provider's responsibility to set all
the parameters.
Important to mention connection providers within a JVM used from multiple threads so adding
internal state is not advised. If any state added then it must be synchronized properly.
- Since:
- 3.1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Checks if this connection provider instance can handle the connection initiated by the driver.abstract Connection
getConnection
(Driver driver, scala.collection.immutable.Map<String, String> options) Opens connection to the database.abstract boolean
modifiesSecurityContext
(Driver driver, scala.collection.immutable.Map<String, String> options) Checks if this connection provider instance needs to modify global security configuration to handle authentication and thus should synchronize access to the security configuration while the given driver is initiating a connection with the given options.abstract String
name()
Name of the service to provide JDBC connections.
-
Constructor Details
-
JdbcConnectionProvider
public JdbcConnectionProvider()
-
-
Method Details
-
canHandle
public abstract boolean canHandle(Driver driver, scala.collection.immutable.Map<String, String> options) Checks if this connection provider instance can handle the connection initiated by the driver. There must be exactly one active connection provider which can handle the connection for a specific driver. If this requirement doesn't met thenIllegalArgumentException
will be thrown by the provider framework.- Parameters:
driver
- Java driver which initiates the connectionoptions
- Driver options which initiates the connection- Returns:
- True if the connection provider can handle the driver with the given options.
-
getConnection
public abstract Connection getConnection(Driver driver, scala.collection.immutable.Map<String, String> options) Opens connection to the database. Since global JVM security configuration change may be needed this API is called synchronized bySecurityConfigurationLock
to avoid race whenmodifiesSecurityContext
returns true for the given driver with the given options.- Parameters:
driver
- Java driver which initiates the connectionoptions
- Driver options which initiates the connection- Returns:
- a
Connection
object that represents a connection to the URL
-
modifiesSecurityContext
public abstract boolean modifiesSecurityContext(Driver driver, scala.collection.immutable.Map<String, String> options) Checks if this connection provider instance needs to modify global security configuration to handle authentication and thus should synchronize access to the security configuration while the given driver is initiating a connection with the given options.- Parameters:
driver
- Java driver which initiates the connectionoptions
- Driver options which initiates the connection- Returns:
- True if the connection provider will need to modify the security configuration when initiating a connection with the given driver with the given options.
- Since:
- 3.1.3
-
name
Name of the service to provide JDBC connections. This name should be unique. Spark will internally use this name to differentiate JDBC connection providers.- Returns:
- (undocumented)
-