Using the Default Data Source
Oracle provides a default data source required by a Java EE 7-compliant runtime. This pre-configured data source can be used by an application to access the Derby Database installed with WebLogic Server.
- What is Default Data Source
Oracle provides a default data source required by a Java EE 7-compliant runtime. - Defining a Custom Default Data Source
You can implement a custom default data source by defining a custom data source descriptor that is bound tojava:comp/DefaultDataSource
or overidding the default data source to point to another JNDI name. - Compatibility Limitations When Using a Default Data Source
Learn about the limitations when using a default data source.
Parent topic: JDBC Data Sources Types
What is Default Data Source
Oracle provides a default data source required by a Java EE 7-compliant runtime.
It is accessible under the JNDI name:
java:comp/DefaultDataSource
which is equivalent to:
@Resource(lookup="java:comp/DefaultDataSource")
DataSource myDS;
You can explicitly bind a Data Source resource reference to the Default data source
using the lookup element of the resource annotation or the lookup-name element of the
resource-ref
deployment descriptor element.
Note:
The Derby database is started by thestartWebLogic
command by default. For more information on starting
and stopping a WebLogic Server instance, see Starting and Stopping Servers in Administering Server Startup and Shutdown for Oracle WebLogic Server.
Characteristics of a Default Data Source
A default data source has the following characteristics:
-
Must be available for each component that is deployed.
-
Only accessible for deployed components, not for data sources that are system resources or stand-alone deployments.
-
Only visible in a console after it has been referenced.
-
Appears as a deployment for each component, like other Java EE deployments.
-
Not configurable.
-
Has the lifecycle of the associated application.
Configuring a Default Data Source
The following table provides the configuration settings that define the WebLogic Server default data source definition:
Table 4-1 Default Data Source Configuration
Attribute | Value |
---|---|
Name | java:comp/DefaultDataSource |
Initial capacity | 0 |
Min capacity | 0 |
Max capacity | 15 |
Classname | org.apache.derby.jdbc.ClientDataSource |
Port | 1527 |
Host | localhost |
Database name | DefaultDataSource |
User | none |
Password | none |
Transactional | false |
MaxStatements | 0 |
MaxIdleTimeout | not set |
Parent topic: Using the Default Data Source
Defining a Custom Default Data Source
You can implement a custom default data source by defining a custom data
source descriptor that is bound to java:comp/DefaultDataSource
or overidding
the default data source to point to another JNDI name.
See:
After the component is deployed, if java:comp/DefaultDataSource
is not available for the component, the WebLogic Server preconfigured default data source is available to the component. However, if you disabled the Derby database by setting DERBY_FLAG=false)
before running startWebLogic.sh
script, the WebLogic Server preconfigured default data source is not available.
Creating a Custom Default Data Source Descriptor
You can configure a data source descriptor that is bound to
java:comp/DefaultDataSource
replacing the preconfigured default data
source. For example, the following provides an example of Java EE 6 annotations in a EAR
application:
@Stateless(mappedName="DSBean")
@DataSourceDefinition(name="java:comp/DefaultDataSource",
className="oracle.jdbc.OracleDriver",
portNumber=1521,
serverName="myServer",
databaseName="myDB",
user="a username",
password="a password",
transactional=false
)
public class DSBean implements DSInterface
. . .
Overriding the Default Data Source
You can override the preconfigured default data source provided by WebLogic Server by updating the JNDI name in the default data source attribute in the configuration of a server or server template to point to another existing data source.
Parent topic: Using the Default Data Source
Compatibility Limitations When Using a Default Data Source
Learn about the limitations when using a default data source.
In releases prior to Weblogic Server 12.2.1, WebLogic Server tries to satisfy
unresolved data source res-ref
references automatically by attempting
to lookup the data source in JNDI using the name of the res-ref
. This
behavior is undefined prior to Java EE 7. This WebLogic Server release uses the default
data source as defined by Java EE 7.
Parent topic: Using the Default Data Source