簡體   English   中英

PostgreSQL在ubuntu本地主機上的連接地址在哪里?

[英]Postgresql on ubuntu localhost connection where address?

我在Ubuntu 14.04上安裝了postgresql的新副本。

sudo apt-get install postgresql postgresql-contrib

我可以輕松地使用psql make db,table等罰款。 但是我有興趣使用java連接並插入一些數據。 但是我不知道地址是什么。 我假設類似:

DriverManager.getConnection(“ jdbc:postgresql://127.0.0.1:8080 / database name”,“ username”,“ password”);

但是我無法連接。 所以問題是在ubuntu上新安裝的psql副本的地址是什么?

PostgreSQL默認在回送地址127.0.0.1(IPv4)和:: 1 IPv6)上偵聽TCP / IP端口5432。 這些通常綁定到主機名“ localhost”。

因此,JDBC URL是:

jdbc:postgressql://localhost:5432/dbname

但是,如果您不提供端口,則假定端口為5432;否則,端口為0。 所有你需要的是

jdbc:postgressql://localhost/dbname

有關更多信息, 請參見手冊


順便說一句,“ psql”是客戶端程序。 PostgreSQL或“ postgres”是服務器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM