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 |
|
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 |
|
AccessKey_Secret | Yes |
|
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 |
|
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