vpc-aejsd98p VPC and subnet-83knqldq subnet. The IP to access Tencent Cloud TCHouse-P is 10.0.6.10, the port number is 5432, and the login account is lambuser.

vpc-aejsd98p VPC and subnet-83knqldq subnet or purchase one if there is none. Log in to the instance and run the following command to install the PostgreSQL client.yum install -y postgresql.x86_64
psql –h10.0.6.10 –p5432 –dpostgres –Ulambuser
pom.xml file:<dependencies><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.2.2</version></dependency></dependencies>
package com.qcloud.snova_conn;import java.io.InputStream;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.ResultSetMetaData;import java.sql.Statement;import java.sql.Timestamp;import java.util.ArrayList;import java.util.List;import java.util.Properties;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import com.yammer.metrics.core.Meter;public class SnovaConn {/** args: vip vport user pwd*/public static void main(String[] args) throws ClassNotFoundException, SQLException {if (args.length < 4){System.out.println("args err");return;}String vip = args[0];String vport = args[1];String userName = args[2];String userPwd = args[3];System.out.printf("vip:%s, vport:%s, userName:%s, userPwd:%s\\n",vip, vport, userName, userPwd);String jdbcUrl = "jdbc:postgresql://" + vip+":"+vport+"/maxluo";System.out.printf("jdbcUrl:%s \\n",jdbcUrl);Class.forName("org.postgresql.Driver");Connection snova = DriverManager.getConnection(jdbcUrl,userName,userPwd);Statement st = snova.createStatement();ResultSet rs = st.executeQuery("select * from test;");while (rs.next()) {System.out.print(rs.getString(1));System.out.print("\\n");}rs.close();st.close();}}
pom.xml configuration<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.qcloud</groupId><artifactId>snova-conn</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>snova-conn</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.40</version></dependency><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.2.2</version></dependency><dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId><version>6.4.0.jre8</version></dependency><dependency><groupId>com.yammer.metrics</groupId><artifactId>metrics-core</artifactId><version>2.2.0</version></dependency><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.1.9</version></dependency></dependencies><build><plugins><plugin><artifactId>maven-assembly-plugin</artifactId><configuration><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><configuration><excludes><exclude>*.properties</exclude><exclude>*.xml</exclude><exclude>*.json</exclude><exclude>*.sh</exclude></excludes></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy-dependencies</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><type>jar</type><includeTypes>jar</includeTypes><outputDirectory>${project.build.directory}/lib</outputDirectory></configuration></execution></executions></plugin></plugins></build></project>
jar file and upload the jar package to the CVM instance (any instance in the VPC subnet where the Tencent Cloud TCHouse-P cluster resides).yum install java
java –cp snova-conn-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.qcloud.snova_conn.SnovaConn 10.0.8.5 5436 lambuser lambpwd11
test table in the maxluo database created previously.

Feedback