Problems encountered during the first JDBC connection to the postgre database and Solutions

Source: Internet
Author: User

1. Install postgre data by default. Use a graphical tool in Windows to create a database, and the connection is normal.

2. problems occurred during JDBC connection.

Connection refused. Check that the hostname and port are correct and that the postmaster

Is accepting TCP/IP connections.

This error is found because the-I parameter is not added when the Postgres service is started. Check that this parameter is not found in the default startup service installed in windows. No data for this parameter

The database can only accept local connections. If you try to modify the attribute of this service, add the parameter-I directly. If it fails, you have to register a service again:
Pg_ctl register-n "postgre-server"-u Postgres-P testpwd-o-I-d "C:/....../Data"
Later, I realized that it was okay to change the listen_addresses settings in PostgreSQL. conf, but I never did.
Listen_addresses = '*'
-D declares the data file path, which can also be declared by setting the system environment variable pgdata.

Restart the service and connect to the database with JDBC
Connection rejected: Fatal: No pg_hba.conf entry for host "10.1.22.77", user "s", Database "jminnet", SSL off.
10.1.22.77 is the IP address of the client. It seems that the 10.1.22.77 entry must be added to pg_mirror.conf.
In pg_hba.conf, there is a 127.0.0.1 entry. Copy it again and change 127.0.0.1 to 10.1.22.77.
Restart the service again and use JDBC to connect to the database!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.