4 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 the Default Data Source

It is accessible under the JNDI name:


which is equivalent to:

DataSource myDS;

You can explicitly bind a DataSource 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.


The Derby database is started by the startWebLogic 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.

The WebLogic Server Default Data Source Definition

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

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.


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:

user="a username",
password="a password",
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. See the following topics in Administering Oracle WebLogic Server with Fusion Middleware Control:

In a partitioned environment, you can override this attribute using the DataSourcePartitionMBean. See Configuring JDBC in Using Oracle WebLogic Server Multitenant.

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 an 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.