skip to main content
Using the Driver : Connecting from an Application : 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.sparksql.SparkSQLDataSource;
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 binary connection:
SparkSQLDataSource mds = new SparkSQLDataSource();
mds.setDescription("My Spark SQL Server");
mds.setServerName("MyServer");
mds.setPortNumber(10000);
mds.setDatabaseName("myDB");
The following example contains the minimum properties for a connection in HTTP mode:
SparkSQLDataSource mds = new SparkSQLDataSource();
mds.setDescription("My Spark SQL Server");
mds.setServerName("MyServer");
mds.setPortNumber(10000);
mds.setDatabaseName("myDB");
mds.setTransportMode("http");
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 binary connection using only the minimum properties:
if (ds instanceof SparkSQLDataSource)
{
SparkSQLDataSource jmds = (SparkSQLDataSource) ds;
System.out.println("description=" + jmds.getDescription());
System.out.println("serverName=" + jmds.getServerName());
System.out.println("portNumber=" + jmds.getPortNumber());
System.out.println("databaseName=" + jmds.getDatabaseName());
System.out.println();
}