Annotation Interface DataSourceDefinition
DataSource to
be registered with JNDI. The DataSource may be configured by
setting the annotation elements for commonly used DataSource
properties. Additional standard and vendor-specific properties may be
specified using the properties element.
The data source will be registered under the name specified in the
name element. It may be defined to be in any valid
Jakarta EE namespace, which will determine the accessibility of
the data source from other components.
A JDBC driver implementation class of the appropriate type, either
DataSource, ConnectionPoolDataSource, or
XADataSource, must be indicated by the className
element. The availability of the driver class will be assumed at runtime.
DataSource properties should not be specified more than once. If the url annotation element contains a DataSource property that was also specified using the corresponding annotation element or was specified in the properties annotation element, the precedence order is undefined and implementation specific:
In the above example, the databaseName, user
and serverName properties were specified as part of the
url property and using the corresponding
annotation elements. This should be avoided.
If the properties annotation element is used and contains a
DataSource property that was also specified using the corresponding
annotation element, the annotation element value takes precedence.
For example:
This would result in the following values being used when configuring the DataSource:
- serverName=luckydog
- portNumber=1527
- databaseName=testDB
- user=lance
- password=secret
- databaseProp=doThis
Vendors are not required to support properties that do not normally
apply to a specific data source type. For example, specifying the
transactional property to be true but supplying
a value for className that implements a data source class
other than XADataSource may not be supported.
Vendor-specific properties may be combined with or used to override standard data source properties defined using this annotation.
DataSource properties that are specified and are not supported
in a given configuration or cannot be mapped to a vendor specific
configuration property may be ignored.
Examples:
Using a URL:
An example lookup of the DataSource from an Jakarta Enterprise Beans:
- Since:
- Common Annotations 1.1
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionName of a database on a server.Description of this data sourceintNumber of connections that should be created when a connection pool is initialized.intIsolation level for connections.intSets the maximum time in seconds that this data source will wait while attempting to connect to a database.intThe number of seconds that a physical connection should remain unused in the pool before the connection is closed for a connection pool.intMaximum number of connections that should be concurrently allocated for a connection pool.intThe total number of statements that a connection pool should keep open.intMinimum number of connections that should be allocated for a connection pool.Password to use for connection authentication.intPort number where a server is listening for requests.String[]Used to specify vendor-specific properties and less commonly usedDataSourceproperties such as: dataSourceName networkProtocol propertyCycle roleName Properties are specified using the format: propertyName=propertyValue with one property per array element.Database server name.booleanSet tofalseif connections should not participate in transactions.A JDBC URL.User name to use for connection authentication.
-
Element Details
-
-
description
String descriptionDescription of this data source- Since:
- 1.1
- Default:
- ""
-
url
String urlA JDBC URL. If theurlannotation element contains a DataSource property that was also specified using the corresponding annotation element, the precedence order is undefined and implementation specific.- Since:
- 1.1
- Default:
- ""
-
user
String userUser name to use for connection authentication.- Since:
- 1.1
- Default:
- ""
-
password
String passwordPassword to use for connection authentication.- Since:
- 1.1
- Default:
- ""
-
databaseName
String databaseNameName of a database on a server.- Since:
- 1.1
- Default:
- ""
-
portNumber
int portNumberPort number where a server is listening for requests.- Since:
- 1.1
- Default:
- -1
-
serverName
String serverNameDatabase server name.- Since:
- 1.1
- Default:
- "localhost"
-
isolationLevel
int isolationLevelIsolation level for connections. The Isolation level must be one of the following:- Connection.TRANSACTION_NONE,
- Connection.TRANSACTION_READ_ UNCOMMITTED,
- Connection.TRANSACTION_READ_COMMITTED,
- Connection.TRANSACTION_REPEATABLE_READ,
- Connection.TRANSACTION_SERIALIZABLE
- Since:
- 1.1
- Default:
- -1
-
transactional
boolean transactionalSet tofalseif connections should not participate in transactions.Default is to enlist in a transaction when one is active or becomes active.
- Since:
- 1.1
- Default:
- true
-
initialPoolSize
int initialPoolSizeNumber of connections that should be created when a connection pool is initialized.Default is vendor-specific
- Since:
- 1.1
- Default:
- -1
-
maxPoolSize
int maxPoolSizeMaximum number of connections that should be concurrently allocated for a connection pool.Default is vendor-specific.
- Since:
- 1.1
- Default:
- -1
-
minPoolSize
int minPoolSizeMinimum number of connections that should be allocated for a connection pool.Default is vendor-specific.
- Since:
- 1.1
- Default:
- -1
-
maxIdleTime
int maxIdleTimeThe number of seconds that a physical connection should remain unused in the pool before the connection is closed for a connection pool.Default is vendor-specific
- Since:
- 1.1
- Default:
- -1
-
maxStatements
int maxStatementsThe total number of statements that a connection pool should keep open. A value of 0 indicates that the caching of statements is disabled for a connection pool.Default is vendor-specific
- Since:
- 1.1
- Default:
- -1
-
properties
String[] propertiesUsed to specify vendor-specific properties and less commonly usedDataSourceproperties such as:- dataSourceName
- networkProtocol
- propertyCycle
- roleName
If a DataSource property is specified in the
propertieselement and the annotation element for the property is also specified, the annotation element value takes precedence.- Since:
- 1.1
- Default:
- {}
-
loginTimeout
int loginTimeoutSets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout.Default is vendor-specific.
- Since:
- 1.1
- Default:
- 0
-