Connecting to local instance of PostgreSql with JDBC

后端 未结 2 499
-上瘾入骨i
-上瘾入骨i 2021-02-07 03:09

I have a running local instance of PostgreSql on a linux machine. When I use psql command from the shell I success to log in without any problem. I need to connect

2条回答
  •  佛祖请我去吃肉
    2021-02-07 03:37

    It's all explained in official documentation.

    This is the relevant part:

    String url = "jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true";
    Connection conn = DriverManager.getConnection(url);
    

提交回复
热议问题