Annotation Type DataSourceDefinition
-
@Target(TYPE) @Retention(RUNTIME) public @interface DataSourceDefinitionAnnotation used to define a containerDataSourceand be registered with JNDI. TheDataSourcemay be configured by setting the annotation elements for commonly usedDataSourceproperties. Additional standard and vendor-specific properties may be specified using thepropertieselement.The data source will be registered under the name specified in the
nameelement. It may be defined to be in any validJava EEnamespace, and will determine the accessibility of the data source from other components.A JDBC driver implementation class of the appropriate type, either
DataSource,ConnectionPoolDataSource, orXADataSource, must be indicated by theclassNameelement. The availability of the driver class will be assumed at runtime.The
urlproperty should not be specified in conjunction with other standard properties for defining the connectivity to the database. If theurlproperty is specified along with other standardDataSourceproperties such asserverNameandportNumber, the more specific properties will take precedence andurlwill be ignored.Vendors are not required to support properties that do not normally apply to a specific data source type. For example, specifying the
transactionalproperty to betruebut supplying a value forclassNamethat implements a data source class other thanXADataSourcemay not be supported.Vendor-specific properties may be combined with or used to override standard data source properties defined using this annotation.
DataSourceproperties 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:
@DataSourceDefinition(name="java:global/MyApp/MyDataSource", className="com.foobar.MyDataSource", portNumber=6689, serverName="myserver.com", user="lance", password="secret" )Using a
URL:
@DataSourceDefinition(name="java:global/MyApp/MyDataSource", className="org.apache.derby.jdbc.ClientDataSource", url="jdbc:derby://localhost:1527/myDB", user="lance", password="secret" )An example lookup of the
DataSourcefrom an EJB:@Stateless public class MyStatelessEJB { @Resource(lookup="java:global/MyApp/myDataSource") DataSource myDB; ... }- Since:
- Common Annotations 1.1
- See Also:
DataSource,XADataSource,ConnectionPoolDataSource
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringclassNameDataSource implementation class name which implements:javax.sql.DataSourceorjavax.sql.XADataSourceorjavax.sql.ConnectionPoolDataSource.java.lang.StringnameJNDI name by which the data source will be registered.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringdatabaseNameName of a database on a server.java.lang.StringdescriptionDescription of this data sourceintinitialPoolSizeNumber of connections that should be created when a connection pool is initialized.intisolationLevelIsolation level for connections.intloginTimeoutSets the maximum time in seconds that this data source will wait while attempting to connect to a database.intmaxIdleTimeThe number of seconds that a physical connection should remain unused in the pool before the connection is closed for a connection pool.intmaxPoolSizeMaximum number of connections that should be concurrently allocated for a connection pool.intmaxStatementsThe total number of statements that a connection pool should keep open.intminPoolSizeMinimum number of connections that should be allocated for a connection pool.java.lang.StringpasswordPassword to use for connection authentication.intportNumberPort number where a server is listening for requests.java.lang.String[]propertiesUsed to specify Vendor specific properties and less commonly usedDataSourceproperties such as:java.lang.StringserverNameDatabase server name.booleantransactionalSet tofalseif connections should not participate in transactions.java.lang.StringurlA JDBC URL.java.lang.StringuserUser name to use for connection authentication.
-
-
-
-
isolationLevel
int isolationLevel
Isolation 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
Default is vendor-specific.
- Since:
- 1.1
- Default:
- -1
-
-
-
properties
java.lang.String[] properties
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.
- Since:
- 1.1
- Default:
- {}
-
-
-
loginTimeout
int loginTimeout
Sets 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
-
-