All Products
Search
Document Center

Hologres:Connect to a virtual warehouse instance

Last Updated:Sep 27, 2024

This topic describes how to connect to a virtual warehouse instance by using Java Database Connectivity (JDBC) or psql.

Connect to Hologres by using JDBC

Syntax

  • No virtual warehouse is explicitly specified in the connection string, and the default virtual warehouse of the connected instance is used.

    jdbc:postgresql:<Endpoint>:<Port>/<database_name>
  • A virtual warehouse is explicitly specified in the connection string.

    jdbc:postgresql://<Endpoint>:<Port>/<database_name>@<warehouse_name>

Parameter description

Parameter

Required

Description

Endpoint

Yes

The endpoint of the Hologres instance.

You can obtain the endpoint of the Hologres instance on the Instance Details page in the Hologres console.

Port

Yes

The port number of the Hologres instance.

You can obtain the port number of the Hologres instance on the Instance Details page in the Hologres console.

database_name

Yes

  • The name of the Hologres database.

  • After you purchase a Hologres instance, a database named postgres is automatically created.

  • You can connect to the postgres database. However, limited resources are allocated to this database. We recommend that you go to the Hologres console and create a database to ensure sufficient resources for your business. For more information, see Create a database.

  • In this example, a Hologres database named demo is connected.

warehouse_name

No

The name of the virtual warehouse that you want to use in the instance.

Examples

  • No virtual warehouse is explicitly specified.

    In this example, you connect to the demo database in the instance named hgpostcn-cn-zz4xxxxxxxxxx in JDBC mode, and the default virtual warehouse is used.

    jdbc:postgresql://hgpostcn-cn-zz4xxxxxxxxxx-cn-shenzhen-vpc-st.hologres.aliyuncs.com:80/demo
  • A virtual warehouse is explicitly specified.

    In this example, you connect to the demo database in the instance named hgpostcn-cn-zz4xxxxxxxxxx in JDBC mode, and the specified virtual warehouse named warehouse_1 is used.

    jdbc:postgresql://hgpostcn-cn-zz4xxxxxxxxxx-cn-shenzhen-vpc-st.hologres.aliyuncs.com:80/demo@warehouse_1

Connect to Hologres by using psql

Syntax

  • No virtual warehouse is explicitly specified in the connection string, and the default virtual warehouse of the connected instance is used.

    PGUSER="<AccessKey_ID>" PGPASSWORD="<AccessKey_Secret>" psql -h <Endpoint> -p <Port> -d <database_name>
  • A virtual warehouse is explicitly specified in the connection string.

    PGUSER="<AccessKey_ID>" PGPASSWORD="<AccessKey_Secret>" psql -h <Endpoint> -p <Port> -d <database_name>@<warehouse_name>

Parameter description

Parameter

Required

Description

AccessKey_ID

Yes

  • Alibaba Cloud account: the AccessKey ID of your Alibaba Cloud account. You can obtain the AccessKey ID from the AccessKey Pair page.

  • Custom account: the username of the custom account. Example: BASIC$abc.

AccessKey_Secret

Yes

  • Alibaba Cloud account: the AccessKey secret of your Alibaba Cloud account.

  • Custom account: the password of the custom account.

Endpoint

Yes

The endpoint of the Hologres instance.

You can obtain the endpoint of the Hologres instance on the Instance Details page in the Hologres console.

Port

Yes

The port number of the Hologres instance.

You can obtain the port number of the Hologres instance on the Instance Details page in the Hologres console.

database_name

Yes

  • The name of the Hologres database.

  • After you purchase a Hologres instance, a database named postgres is automatically created.

  • You can connect to the postgres database. However, limited resources are allocated to this database. We recommend that you go to the Hologres console and create a database to ensure sufficient resources for your business. For more information, see Create a database.

  • In this example, a Hologres database named demo is connected.

warehouse_name

No

The name of the virtual warehouse that you want to use in the instance.

Examples

  • No virtual warehouse is explicitly specified.

    In this example, you connect to the demo database in the instance named hgpostcn-cn-zz4xxxxxxxxxx by using psql, and the default virtual warehouse is used.

    PGUSER="xxx" PGPASSWORD="xxx" psql -h hgpostcn-cn-zz4xxxxxxxxxx-cn-shenzhen-vpc-st.hologres.aliyuncs.com -p 80 -d demo
  • A virtual warehouse is explicitly specified.

    In this example, you connect to the demo database in the instance named hgpostcn-cn-zz4xxxxxxxxxx by using psql, and the specified virtual warehouse named warehouse_1 is used.

    PGUSER="xxx" PGPASSWORD="xxx" psql -h hgpostcn-cn-zz4xxxxxxxxxx-cn-shenzhen-vpc-st.hologres.aliyuncs.com -p 80 -d demo@warehouse_1