我在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副本的地址是什么?
答案 0 :(得分:0)
默认情况下,PostgreSQL在环回地址127.0.0.1(IPv4)和:: 1 IPv6上侦听TCP / IP端口5432。这些通常绑定到主机名' localhost'。
所以JDBC URL是:
jdbc:postgressql://localhost:5432/dbname
但是,如果您不提供端口,则假定该端口为5432;你需要的只是
jdbc:postgressql://localhost/dbname
了解更多信息see the manual。
BTW," psql"是客户端程序。 PostgreSQL或" postgres"是服务器。