MaxCompute allows you to use the database management tool DataGrip to access MaxCompute projects and manage data. This topic describes how to use a MaxCompute Java Database Connectivity (JDBC) driver to connect DataGrip to a MaxCompute project and use DataGrip to manage data.
Background information
DataGrip is a database management tool for developers. It provides an easy method for developers to query, create, and manage databases. Databases can work on on-premises machines, servers, or the cloud. For more information about DataGrip, see DataGrip.
Prerequisites
Make sure that the following conditions are met:
A MaxCompute project is created.
For more information about how to create a MaxCompute project, see Create a MaxCompute project.
The AccessKey pair of your Alibaba Cloud account that is used to access the MaxCompute project is obtained.
You can obtain the AccessKey pair on the AccessKey Pair page.
The package of MaxCompute JDBC driver V3.2.8 or later is downloaded. This package includes the
jar-with-dependencies
JAR file.MaxCompute JDBC driver V3.2.9 is used in this topic.
DataGrip is downloaded and installed.
For more information about how to install DataGrip, see Install DataGrip.
DataGrip 2021.1.3 is used in this topic.
Procedure
To connect DataGrip to MaxCompute, perform the following steps:
Step 1: Add a MaxCompute JDBC driver
Upload the package of the MaxCompute JDBC driver to DataGrip. Then, DataGrip can use the driver to access the MaxCompute project.
Step 2: Connect DataGrip to MaxCompute
Configure connection parameters to connect DataGrip to the MaxCompute project.
Step 3: Use DataGrip to manage the MaxCompute project
Manage the MaxCompute project on DataGrip based on the established data connection.
Step 1: Add a MaxCompute JDBC driver
Start DataGrip.
Click New Project to create a project named MaxCompute_test.
On the page that appears, click the icon. In the Data Sources and Drivers dialog box, click the Drivers tab, add the JAR package of the MaxCompute JDBC driver, configure the Name and Class parameters, and then click Apply.
In the Driver Files section, click the icon and select Custom JARs... to upload the JAR package of the MaxCompute JDBC driver, such as
odps-jdbc-3.2.9-jar-with-dependencies.jar
, from your on-premises machine.Parameter
Description
Name
The name of the driver that you want to add, such as MaxCompute.
Class
After the JAR package of the MaxCompute JDBC driver is uploaded, select com.aliyun.odps.jdbc.OdpsDriver from the Class drop-down list on the General tab.
Step 2: Connect DataGrip to MaxCompute
On the Data Sources tab of the Data Sources and Drivers dialog box, click the icon and select the MaxCompute data source.
You can also click the Drivers tab in the Data Sources and Drivers dialog box and click Create Data Source to add the MaxCompute data source.
In the dialog box that appears, configure connection parameters. The following table describes the connection parameters.
Parameter
Description
Name
The name of the new data connection, which is used to distinguish the connections of different databases in the system. In this topic, set this parameter to MCtoDG.
User
The AccessKey ID that is used to access the MaxCompute project.
You can obtain the AccessKey ID on the AccessKey Pair page.
Password
The AccessKey secret that corresponds to the AccessKey ID.
You can obtain the AccessKey secret on the AccessKey Pair page.
URL
The URL that is used to connect to the MaxCompute project. The format is
jdbc:odps:<MaxCompute_endpoint>?project=<MaxCompute_project_name>[&interactiveMode={true|false}]
. Delete theangle brackets (<>)
when you configure this parameter. Parameters:<MaxCompute_endpoint>: required. The endpoint of MaxCompute. Configure this parameter based on the region where the MaxCompute project resides.
For more information about the endpoints of MaxCompute in different regions, see Endpoints.
<MaxCompute_project_name>: required. The name of the MaxCompute project.
This parameter specifies the name of your MaxCompute project instead of the DataWorks workspace to which the MaxCompute project corresponds. You can log on to the MaxCompute console, select the region where your MaxCompute project resides in the top navigation bar, and then view the name of the MaxCompute project on the Project management tab.
interactiveMode: optional. This parameter specifies whether to enable the MaxCompute Query Acceleration (MCQA) feature.
If you want to enable the MCQA feature, add
&interactiveMode=true
to the end of the URL. For more information about the MCQA feature, see Query acceleration.
useProjectTimeZone: optional. This parameter specifies whether to use the time zone. If you need to keep the time zone of DataGrip consistent with that of the MaxCompute server, append the
&useProjectTimeZone=true
configuration to the URL.
Click Test Connection. If the message shown in the following figure appears, click OK.
Step 3: Use DataGrip to manage the MaxCompute project
After you connect DataGrip to MaxCompute, you can view the established connection in the left-side pane. You can write SQL scripts to manage the MaxCompute project. For more information, see the DataGrip help information.
View all existing tables
You can query the information about all existing tables that are listed under the established MaxCompute connection.
Query a table schema
You can click the table that you want to query under the established MaxCompute connection, write SQL scripts in the right-side SQL code editor, and execute the SQL scripts to query the schema of the table.
Query table data
You can click the table that you want to query under the established MaxCompute connection, write SQL scripts in the right-side SQL code editor, and execute the SQL scripts to query the data of the table.