| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
@Target(value=TYPE) @Retention(value=RUNTIME) public @interface DataSourceDefinition
Annotation used to define a container DataSource and
 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
 Java EE namespace, and 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.
 The url property should not be specified in conjunction with
 other standard properties for defining the connectivity to the database.
 If the url property is specified along with other standard
 DataSource properties
 such as serverName and portNumber, the more
 specific properties will take precedence and url will be
 ignored.
 
 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:
 
  
   @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 DataSource from an EJB:
 
 @Stateless
 public class MyStatelessEJB {
   @Resource(lookup="java:global/MyApp/myDataSource")
    DataSource myDB;
      ...
 }
 
 
DataSource, 
XADataSource, 
ConnectionPoolDataSource| Required Element Summary | |
|---|---|
 java.lang.String | 
className
DataSource implementation class name which implements: javax.sql.DataSource or javax.sql.XADataSource
 or javax.sql.ConnectionPoolDataSource. | 
 java.lang.String | 
name
JNDI name by which the data source will be registered.  | 
| Optional Element Summary | |
|---|---|
 java.lang.String | 
databaseName
Name of a database on a server.  | 
 java.lang.String | 
description
Description of this data source  | 
 int | 
initialPoolSize
Number of connections that should be created when a connection pool is initialized.  | 
 int | 
isolationLevel
Isolation level for connections.  | 
 int | 
loginTimeout
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.  | 
 int | 
maxIdleTime
The number of seconds that a physical connection should remain unused in the pool before the connection is closed for a connection pool.  | 
 int | 
maxPoolSize
Maximum number of connections that should be concurrently allocated for a connection pool.  | 
 int | 
maxStatements
The total number of statements that a connection pool should keep open.  | 
 int | 
minPoolSize
Minimum number of connections that should be allocated for a connection pool.  | 
 java.lang.String | 
password
Password to use for connection authentication.  | 
 int | 
portNumber
Port number where a server is listening for requests.  | 
 java.lang.String[] | 
properties
Used to specify Vendor specific properties and less commonly used DataSource properties such as: | 
 java.lang.String | 
serverName
Database server name.  | 
 boolean | 
transactional
Set to false if connections should not participate
 in transactions. | 
 java.lang.String | 
url
A JDBC URL.  | 
 java.lang.String | 
user
User name to use for connection authentication.  | 
| Element Detail | 
|---|
public abstract java.lang.String name
public abstract java.lang.String className
javax.sql.DataSource or javax.sql.XADataSource
 or javax.sql.ConnectionPoolDataSource.
public abstract java.lang.String description
public abstract java.lang.String url
url property is specified along with
 other standard DataSource properties
 such as serverName and portNumber, the more
 specific properties will take precedence and url will be
 ignored.
public abstract java.lang.String user
public abstract java.lang.String password
public abstract java.lang.String databaseName
public abstract int portNumber
public abstract java.lang.String serverName
public abstract int isolationLevel
Default is vendor-specific.
public abstract boolean transactional
false if connections should not participate
 in transactions.
 Default is to enlist in a transaction when one is active or becomes active.
public abstract int initialPoolSize
Default is vendor-specific
public abstract int maxPoolSize
Default is vendor-specific.
public abstract int minPoolSize
Default is vendor-specific.
public abstract int maxIdleTime
Default is vendor-specific
public abstract int maxStatements
Default is vendor-specific
public abstract java.lang.String[] properties
DataSource properties such as:
 
Properties are specified using the format: propertyName=propertyValue with one property per array element.
public abstract int loginTimeout
Default is vendor-specific.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.
Generated on 10-February-2011 12:41