Example data source
- Last Updated: August 26, 2024
- 1 minute read
- DataDirect Connectors
- JDBC
- Oracle Database 6.0
- Documentation
To configure a data source using the example files, you will need to create a data source definition. The content required to create a data source definition is divided into three sections.
First, you will need to import the data source class. For example:
import com.ddtek.jdbcx.oracle.OracleDataSource;Next,
you will need to set the values and define the data source. For example, the following
definition contains the minimum properties required for a connection:Note:
- Setting the password using a data source is generally not recommended. The data source persists all properties, including the Password property, in clear text.
- In a JDBC data source, string values must be enclosed in double quotation
marks, for example,
setUser("abc@defcorp.com").
OracleDataSource mds = new OracleDataSource();
mds.setDescription("My Oracle Datasource");
mds.setServerName("MyServer");
mds.setUser("User123");
mds.setPassword("secret");
Note: If you do not specify a value for SID property, the
driver automatically uses
Optionally, you can configure the example application to print out the data
source attributes. Note that this code is specific to the driver and should only be used in
the example application. For example, you would add the following section for a connection
using only the minimum properties:ORCL, as that's the default
value.if (ds instanceof OracleDataSource)
{
OracleDataSource jmds = (OracleDataSource) ds;
System.out.println("description=" + jmds.getDescription());
System.out.println("serverName=" + jmds.getServerName());
System.out.println("user=" + jmds.getUser());
System.out.println("password=" + jmds.getPassword());
System.out.println();
}