public static interface DataSource.Builder
DataSource
s. This type is
immutable once configured. No property can be set more than once. No
property can be set after build()
is called.Modifier and Type | Method | Description |
---|---|---|
DataSource |
build() |
Return a DataSource configured as specified.
|
DataSource.Builder |
connectionProperty(ConnectionProperty property,
java.lang.Object value) |
Specify the value of a
Connection property that will be set on all
Connection s produced by the built DataSource . |
DataSource.Builder |
defaultConnectionProperty(ConnectionProperty property,
java.lang.Object value) |
Specify the value of a
Connection property that will be set by default on
all Connection s produced by this DataSource . |
default DataSource.Builder |
password(java.lang.String password) |
A convenience method for setting the
JdbcConnectionProperty.PASSWORD . |
DataSource.Builder |
registerConnectionProperty(ConnectionProperty property) |
Make a user defined property known to the implementation.
|
default DataSource.Builder |
url(java.lang.String url) |
A convenience method for setting the
JdbcConnectionProperty.URL . |
default DataSource.Builder |
username(java.lang.String name) |
A convenience method for setting the
JdbcConnectionProperty.USER . |
default DataSource.Builder url(java.lang.String url)
JdbcConnectionProperty.URL
.url
- the value to be set for JdbcConnectionProperty.URL
DataSource.Builder
connectionProperty(java.sql2.ConnectionProperty,java.lang.Object)
default DataSource.Builder username(java.lang.String name)
JdbcConnectionProperty.USER
.name
- the value to be set for JdbcConnectionProperty.USER
DataSource.Builder
connectionProperty(java.sql2.ConnectionProperty,java.lang.Object)
default DataSource.Builder password(java.lang.String password)
JdbcConnectionProperty.PASSWORD
.password
- the value to be set for JdbcConnectionProperty.PASSWORD
DataSource.Builder
connectionProperty(java.sql2.ConnectionProperty,java.lang.Object)
DataSource.Builder defaultConnectionProperty(ConnectionProperty property, java.lang.Object value)
Connection
property that will be set by default on
all Connection
s produced by this DataSource
. A different value can be set
for a particular Connection
via Connection.Builder.property(java.sql2.ConnectionProperty, java.lang.Object)
.property
- the ConnectionProperty
to be set. May not be null
.value
- the value to be set for property
DataSource.Builder
java.lang.IllegalArgumentException
- if property.validate(value)
does not
return true
. If it throws an Exception
that Exception
is the cause. Or if
this property has been specified previously to this method or
connectionProperty(java.sql2.ConnectionProperty,java.lang.Object)
.java.lang.IllegalStateException
- if build()
has previously been called.DataSource.Builder connectionProperty(ConnectionProperty property, java.lang.Object value)
Connection
property that will be set on all
Connection
s produced by the built DataSource
. Attempting to set a
different value via Connection.Builder.property(java.sql2.ConnectionProperty, java.lang.Object)
will throw
IllegalArgumentException
.property
- the ConnectionProperty
to set. May not be null
.value
- the value to set as the default for property
DataSource.Builder
java.lang.IllegalArgumentException
- if property.validate(value)
does not
return true
. If it throws an Exception
that Exception
is the cause. Or if
this property has been specified previously to this method or
defaultConnectionProperty(java.sql2.ConnectionProperty,java.lang.Object)
.java.lang.IllegalStateException
- if build()
has previously been called.DataSource.Builder registerConnectionProperty(ConnectionProperty property)
DataSource
doesn't know about the property then it cannot know to set the
default value. Registering a property already known to the DataSource is
a no-op.property
- the ConnectionProperty
to make known. May not be null
.java.lang.IllegalStateException
- if build()
has previously been called.DataSource build()
DataSource
. Not null
.java.lang.IllegalArgumentException
- if unable to return a DataSource
due to
problems with the configuration such is missing or conflicting properties.Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
DRAFT JDBC 4.4 EA