How to connect (Py)Spark to Postgres database using JDBC

前端 未结 1 1912
故里飘歌
故里飘歌 2020-12-17 05:19

I have followed instructions from this posting to read data from an existing Postgres database with table named \"objects\" as defined and created by the Objects

相关标签:
1条回答
  • 2020-12-17 05:49

    Problems with name resolving are indicated by org.postgresql.util.PSQLException and don't result in NPE. The source of the issue is actually a connection string and in particular the way you provide user credentials. At first glance it looks like a bug but if you're looking for a quick solution you can either use URL properties:

    url = 'jdbc:postgresql://PG_SERVER_IP/db_name?user=PG_USER&password=PASSWORD'
    

    or properties argument:

    properties = {
        "user": "PG_USER",
        "password": "PASSWORD",
        "driver": "org.postgresql.Driver"
    }
    
    0 讨论(0)
提交回复
热议问题