Establishing a Connection
Creating a JDBC Data Source
You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Greenplum consists of three basic steps:
- Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
- Provide the driver class. For example:
- Provide the JDBC URL. For example:
jdbc:greenplum:User=user;Password=admin;Database=dbname;Server=127.0.0.1;Port=5432 or jdbc:cdata:greenplum:User=user;Password=admin;Database=dbname;Server=127.0.0.1;Port=5432
The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:greenplum:" or "jdbc:cdata:greenplum:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to Greenplum
To connect to Greenplum, set the Server, Port (the default port is 5432), and Database connection properties and set the User and Password you wish to use to authenticate to the server. If the Database property is not specified, the driver connects to the user's default database (it will be the same name as the user).
The CData JDBC Driver for Greenplum supports the md5, password, Kerberos and SASL (particulary, SCRAM-SHA-256) authentication methods.
The specific authentication method is setup in the pg_hba.conf file on the Greenplum Server. You may find instructions about authentication setup on the Greenplum Server here. The md5, password and SASL authentication methods do not require additional setup by the CData JDBC Driver for Greenplum.
Authenticating with Kerberos
The authentication with Kerberos is initiated by Greenplum Server when the CData JDBC Driver for Greenplum is trying to connect to it. You should setup Kerberos on the Greenplum Server to activate this authentication method. Once you have Kerberos authentication setup on the Greenplum Server, see Using Kerberos for details on how to authenticate with Kerberos by the driver.