Quick Start: Progress® DataDirect® for JDBC for Apache Spark SQL Driver

The following information enables you to connect with and test your driver immediately after installation. For installation instructions, refer to the Progress DataDirect for JDBC Drivers Installation Guide. This Quick Start covers the following topics:

Connecting to a Database

Testing the Connection

Tuning the Driver for Optimal Performance

Connecting to a Database

Once the driver is installed, you can connect from your application to your data store in two ways: using the JDBC Driver Manager or using a JNDI data source. The following section provides information you need to get started using the driver with the Driver Manager. For information on using data sources, refer to the Progress DataDirect for JDBC for Apache Spark SQL User's Guide.

Environment Setup

Set your system CLASSPATH to include the following entry:

install_dir/lib/sparksql.jar
Windows Example
CLASSPATH=.;C:\Program Files\Progress\DataDirect\JDBC_60\lib\sparksql.jar
UNIX/Linux Example
CLASSPATH=.:/opt/Progress/DataDirect/JDBC_60/lib/sparksql.jar

Driver Manager

To establish a database connection using the Driver Manager, your application must register the class name of the JDBC driver with the Driver Manager using the Class.forName() method and specifying the driver class name as the argument. The application must then invoke the DriverManager.getConnection() method supplying a connection URL.

IMPORTANT: Java SE 6 and higher automatically registers the driver with the JDBC Driver Manager. Therefore, if you are using Java SE 6 or higher as a JVM, you do not need to register the driver and can skip this step.

The classname and connection URL syntax for the Apache Spark SQL driver are:

Driver Classname:

com.ddtek.jdbc.sparksql.SparkSQLDriver

Connection URL:

jdbc:datadirect: sparksql://<host>:<port>;[property=value[;...]]

For example, a connection URL might take the following form:

jdbc:datadirect:sparksql://MyServer:10000;DatabaseName=Test;

UserName=admin;Password=adminpass

Example

// Register the driver with the driver manager.
// If using Java SE 6 or higher, you can omit this step. 
// Java SE 6 and higher automatically registers the driver. 
Class.forName("com.ddtek.jdbc.sparksql.SparkSQLDriver");
// Establish the Connection
String url = "jdbc:datadirect:sparksql://MyServer:10000;DatabaseName=Test;"
Connection con = DriverManager.getConnection(url, "test04", "test04");
// Verify the Connection
DatabaseMetaData metaData = con.getMetaData();
System.out.println("Database Name: " + metaData.getDatabaseProductName());
System.out.println("Database Version: " + 
metaData.getDatabaseProductVersion());

Testing the Connection

Take the following steps to test your connection with DataDirect Test™:

1.      Start DataDirect Test by running testforjdbc.bat or testforjdbc.sh in the install_dir/testforjdbc directory, where install_dir is your installation directory.

2.      Click Press Here to Continue.

3.      From the Connection menu, select Connect to DB.

4.      Select the appropriate template for your data source and specify values for the appropriate connection properties. Specify your user name and password if required. Click OK.

5.      A new connection window opens if the connection information was entered correctly. If the connection cannot be established, an error is displayed in the JDBC/Database Output window.

For more information about DataDirect Test, refer to the User's Guide.

Tuning the Driver for Optimal Performance

The driver has connection properties that directly affect performance. To tune the driver for optimal performance, set the following connection properties:

If you know the typical fetch size for your application

Set ArrayFetchSize to suit your environment. The value for ArrayFetchSize specifies the number of cells used to calculate the maximum number of rows for a fetch. When given as a negative integer, the driver overrides any settings on the statement level, such as setFetchSize(). When given as a positive integer, settings on the statement level are not overridden.

If you want to increase the amount of insensitive result set data the driver caches instead of writing this data to disk

Set InsensitiveResultSetBufferSize to a value greater than the default value of 2048 (KB). To prevent the driver from writing insensitive result set data to disk, set this property to -1.

If your application uses statement pooling and the driver is not running from within an application server or from within another application that provides its own statement pooling

Set MaxStatements to x where x is a positive integer that represents a number of pooled prepared statements.

If your application does not need the benefits normally associated with Clobs

Set StringDescribeType to varchar (default).

If your application needs to access tables and views owned only by the current user

Set UseCurrentSchema to true.

© 2015. Progress Software Corporation. All rights reserved.