You must obtain the JDBC URL of your MaxCompute project before you connect an SQL client to the project.

MaxCompute Lightning is developed based on PostgreSQL 8.2. MaxCompute Lightning only supports SELECT queries on existing MaxCompute tables. For more information, see Queries and Functions and Operators.

JDBC URLs are named in the following format:
jdbc:postgresql://endpoint:port/database
The following table describes the parameters used to establish a JDBC connection.
Parameter Value Description
endpoint The endpoint used to access MaxCompute Lightning in the specified network environment in the specified region. For example, to access MaxCompute Lightning in the China (Shanghai) region over the Internet, set the endpoint to lightning.cn-shanghai.maxcompute.aliyun.com. For more information, see Access domain name.
port The port number of the MaxCompute project. Example: 443. N/A
database The name of the MaxCompute project. N/A
user The AccessKey ID of your Alibaba Cloud account. N/A
password The AccessKey secret of your Alibaba Cloud account. N/A
ssl Specifies whether to connect to MaxCompute Lightning by using Secure Sockets Layer (SSL). Example: true. By default, SSL is enabled on the MaxCompute Lightning server. Therefore, you must enable SSL on the client to connect to MaxCompute Lightning.
prepareThreshold The number of PreparedStatement executions required before the JDBC driver switches over to use server-side prepared statements. Example: 0. Optional. We recommend that you set prepareThreshold to 0 if you use the PreparedStatement feature of JDBC.
preferQueryMode Specifies which mode is used to execute queries. Example: simple. Optional. We recommend that you set this parameter if you specify filter conditions to filter out unnecessary partitions in PreparedStatement.

An example JDBC URL is jdbc:postgresql://lightning.cn-shanghai.maxcompute.aliyun.com:443/myproject.

To establish a connection to your MaxCompute project by using this URL, you must set the user, password, and ssl parameters.

You can also add the parameters to the JDBC URL to connect to your MaxCompute project. Example:
jdbc:postgresql://lightning.cn-shanghai.maxcompute.aliyun.com:443/myproject? ssl=true& prepareThreshold=0&user=xxx&password=yyy
where:
  • lightning.cn-shanghai.maxcompute.aliyun.com: the endpoint in the China (Shanghai) region.
  • myproject: the name of the MaxCompute project to access.
  • ssl=true: indicates that SSL is enabled.
  • xxx: the AccessKey ID of your Alibaba Cloud account.
  • yyy: the AccessKey secret of your Alibaba Cloud account.