skip to main content
Getting started : Connecting using data sources : Creating data sources : Example data source
  

Try DataDirect Drivers Now
Example data source
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.sqlserver.SQLServerDataSource;
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:
SQLServerDataSource mds = new SQLServerDataSource();
mds.setDescription("My SQL Server Datasource");
mds.setServerName("MyServer");
mds.setPortNumber(1433);
mds.setUser("User123");
mds.setPassword("secret");
Finally, you will need to 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:
if (ds instanceof SQLServerDataSource)
{
SQLServerDataSource jmds = (SQLServerDataSource) ds;
System.out.println("description=" + jmds.getDescription());
System.out.println("serverName=" + jmds.getServerName());
System.out.println("portNumber=" + jmds.getPortNumber());
System.out.println("user=" + jmds.getUser());
System.out.println("password=" + jmds.getPassword());
System.out.println();
}