Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ GaussDB(DWS)/ Troubleshooting/ JDBC/ODBC/ Database Connection Fails

Database Connection Fails

Updated on 2025-01-06 GMT+08:00

Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Possible cause: The network between the client and server is disconnected, the port is incorrect, or the CN to be connected is abnormal.

Solution:
  • On the client, ping the IP address of the server to check whether the network connection is normal. If the network connection is abnormal, rectify the network fault.
  • Check whether the port for connecting to the CN in the URL is correct. If the port is incorrect, correct it (the default port is 8000).

FATAL: Invalid username/password,login denied.

Possible cause: The username or password is incorrect.

Solution: Use the correct database username and password.

No suitable driver found for XXXX

Possible cause: The format of the URL used for establishing the JDBC connection is wrong.

Solution: Correct the URL format.
  • The URL format of gsjdbc4.jar is jdbc:postgresql://host:port/database.
    • The version is 8.1.x when the pom dependency is used.
  • The URL format of gsjdbc200.jar is jdbc:gaussdb://host:port/database.
    • The version is 8.1.x-200 when the pom dependency is used.

conflict

Possible cause: The JDBC JAR package conflicts with an application. For example, JDBC and an application have classes with the same path and name.

  • gsjdbc4.jar conflicts with the open-source postgresql.jar because they have the same class name.
  • gsjdbc4.jar included other tools, such as fastjson, required for IAM features. This tool conflicts with fastjson in an application.

Solution:

  • For the open-source postgresql.jar file, use gsjdbc200.jar instead and use different URL format and driver path. Change the driver name from org.postgresql.Driver to com.huawei.gauss200.jdbc.Driver, and change the URL format from org:postgresql://host:port/database to jdbc:gaussdb://host:port/database.
  • If the JAR package introduced by JDBC conflicts with that introduced by an application, use the shade of Maven to modify the class path in the JAR package.
  • Check whether the JDBC driver is gsjdbc4.jar or gsjdbc200.jar. If gsjdbc4.jar is used, replace it with gsjdbc200.jar and try to establish a connection.

    NOTE:

    For the pom dependency, replace the 8.1.x version with the 8.1.x-200 version.

org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command Session unused timeout

Possible cause: The connection is disconnected due to session timeout.

Solution: Check the timeout configuration on the CN and the JDBC client. Increase the timeout interval or disable the timeout configuration.

  1. Check the CN logs where the error is reported. If the log contains session unused timeout, there is session timeout.

    Solution:

    1. Log in to the DWS console and click the name of the target cluster.
    2. On the displayed page, click the Parameters tab and search for session_timeout to view the timeout interval.
    3. Set the values of session_timeout on CNs and DNs to 0. For details, see Modifying Database Parameter"Modifying Database Parameters" in the GaussDB(DWS) User Guide.

Connection refused: connect.

Possible cause: The default driver of the third-party tool is incompatible.

Solution: Replace the JDBC driver package and check whether the connection is normal.

Connections could not be acquired from the underlying database!

Possible causes:

  • The driver setting is incorrect.
  • The database connection address is correct.
  • The password or account is incorrect.
  • The database is not started or you do not have the permission to access the database.
  • The required driver JAR package is not imported to the project.

Solution:

  • Check the driver configuration and correct it.
    • gsjdbc4.jar driver=org.postgresql.Driver
    • gsjdbc200.jar driver=com.huawei.gauss200.jdbc.Driver
  • Check the database connection address and correct it.
    • For gsjdbc4.jar, the format is jdbc:postgresql://host:port/database.
    • For gsjdbc200.jar, the format is jdbc:gaussdb://host:port/database.
  • Use the correct database username and password.
  • Check whether the database is started or the access permission has been obtained.
  • Check whether the used JDBC driver is gsjdbc4.jar or gsjdbc200.jar. Use the correct JDBC driver JAR package.

    • gsjdbc4.jar: The gsjdbc4.jar driver package is compatible with PostgreSQL. Its class names and class structures are the same as those of the PostgreSQL driver. PostgreSQL applications can be directly migrated to the current system.
    • gsjdbc200.jar: If a JVM process needs to access PostgreSQL and GaussDB(DWS) at the same time, this driver package must be used. In this package, the main class name is com.huawei.gauss200.jdbc.Driver (that is, org.postgresql is replaced with com.huawei.gauss200.jdbc). The URL prefix of the database connection is jdbc:gaussdb. Other parameters are the same as those of gsjdbc4.jar.

The JDBC DEV environment is normal. The test environment cannot be connected and a null pointer error or a URI error "uri is not hierarchical" is reported.

Problem analysis: Some virtual environments do not support the function of obtaining extended parameters. Therefore, you need to disable the function

Solution: Add connection configuration connectionExtraInfo=false. For details, see Using a JDBC Driver to Connect to a DatabaseUsing a JDBC Driver to Connect to a Database.

1
jdbc:postgresql://host:port/database?connectionExtraInfo=false

An error is reported when the open-source JDBC SSL mode is used to connect to DWS

Possible cause: SSL full verification is not enabled to check whether the URL is completely matched when the open-source JDBC is used.

Solution: Add sslmode=require for the open-source connection.

1
jdbc:postgresql://host:port/database?sslmode=require

Connection cannot be converted to BaseConnection when the connection pool is used to obtain connections in the CopyManager scenario

Possible cause: BaseConnection is a non-public class. The connection pool object needs to be unwrapped to obtain the original PGConnection.

Solution: Unwrap the object and return the original object to allow access to non-public methods.

1
2
3
4
5
// Unwrap
PGConnection unwrap = connection.unwrap(PGConnection.class);
// Convert
BaseConnection baseConnection = (BaseConnection)unwrap;
CopyManager copyManager = new CopyManager(baseConnection);

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback