Annotation Interface DataSourceDefinition
@Target(TYPE)
@Retention(RUNTIME)
@Repeatable(DataSourceDefinitions.class)
public @interface DataSourceDefinition
Defines a data source for dependency injection via the
Resource
annotation. This annotation allows developers to declaratively specify the properties
of a JDBC data source, including connection details, pool sizing, and transactional
behavior. The container creates and manages the data source based on the specified
configuration, making it available for injection into application components.- Since:
- Common Annotations 1.1
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the name of the database to connect to.Provides a human-readable description of the data source for documentation and administrative purposes.intSpecifies the number of connections to create when the connection pool is initialized.intSpecifies the transaction isolation level for connections from this data source, using the constants defined inConnection.intSpecifies the maximum time in seconds that the driver will wait when attempting to connect to the database.intSpecifies the maximum idle time in seconds before a connection is closed and removed from the pool.intSpecifies the maximum number of connections that the pool may create.intSpecifies the maximum number of prepared statements that may be cached per connection in the pool.intSpecifies the minimum number of connections that the pool must maintain.Specifies the password for the database user account used to establish connections.intSpecifies the network port number on which the database server is listening.String[]Specifies additional connection properties in the form "name=value" strings.Specifies the host name or IP address of the database server.booleanIndicates whether connections from this data source support container-managed transactions.Specifies the JDBC connection URL for the database.Specifies the database user name used to establish connections.
-
Element Details
-
className
String classNameSpecifies the fully qualified class name of the JDBC driver or the Jakarta Connector connection factory class that implements this data source.- Returns:
- the fully qualified class name of the data source implementation
-
name
String nameSpecifies the JNDI name under which the data source will be registered. This is the lookup name used for dependency injection or explicit JNDI lookup of the data source.- Returns:
- the JNDI name for the data source
-
description
String descriptionProvides a human-readable description of the data source for documentation and administrative purposes.- Returns:
- the description of the data source
- Default:
""
-
url
String urlSpecifies the JDBC connection URL for the database. This URL is used by the driver to establish connections to the database server.- Returns:
- the JDBC connection URL
- Default:
""
-
user
String userSpecifies the database user name used to establish connections.- Returns:
- the database user name
- Default:
""
-
password
String passwordSpecifies the password for the database user account used to establish connections.- Returns:
- the database password
- Default:
""
-
databaseName
String databaseNameSpecifies the name of the database to connect to. This is used in conjunction with the server name and port number to locate the target database.- Returns:
- the database name
- Default:
""
-
portNumber
int portNumberSpecifies the network port number on which the database server is listening. A value of -1 indicates the default port for the database type.- Returns:
- the database server port number, or -1 for the default
- Default:
-1
-
serverName
String serverNameSpecifies the host name or IP address of the database server.- Returns:
- the database server host name, defaulting to "localhost"
- Default:
"localhost"
-
isolationLevel
int isolationLevelSpecifies the transaction isolation level for connections from this data source, using the constants defined inConnection. A value of -1 indicates the database default isolation level should be used.- Returns:
- the transaction isolation level, or -1 for the database default
- Default:
-1
-
transactional
boolean transactionalIndicates whether connections from this data source support container-managed transactions. When true, the data source participates in Jakarta Transactions.- Returns:
- true if the data source participates in container-managed transactions
- Default:
true
-
initialPoolSize
int initialPoolSizeSpecifies the number of connections to create when the connection pool is initialized. A value of -1 indicates the container default should be used.- Returns:
- the initial number of connections in the pool, or -1 for default
- Default:
-1
-
maxPoolSize
int maxPoolSizeSpecifies the maximum number of connections that the pool may create. A value of -1 indicates the container default should be used.- Returns:
- the maximum pool size, or -1 for the container default
- Default:
-1
-
minPoolSize
int minPoolSizeSpecifies the minimum number of connections that the pool must maintain. A value of -1 indicates the container default should be used.- Returns:
- the minimum pool size, or -1 for the container default
- Default:
-1
-
maxIdleTime
int maxIdleTimeSpecifies the maximum idle time in seconds before a connection is closed and removed from the pool. A value of -1 indicates no idle timeout.- Returns:
- the maximum idle time in seconds, or -1 for no timeout
- Default:
-1
-
maxStatements
int maxStatementsSpecifies the maximum number of prepared statements that may be cached per connection in the pool. A value of -1 indicates the container default.- Returns:
- the maximum cached prepared statements per connection, or -1 for default
- Default:
-1
-
properties
String[] propertiesSpecifies additional connection properties in the form "name=value" strings. These properties are passed to the JDBC driver during connection establishment.- Returns:
- the array of additional connection properties
- Default:
{}
-
loginTimeout
int loginTimeoutSpecifies the maximum time in seconds that the driver will wait when attempting to connect to the database. A value of 0 means no timeout.- Returns:
- the login timeout in seconds, or 0 for no timeout
- Default:
0
-