Spark mode - JDBC source
Read
Dataset<Row> sparkDataset = spark.read()
                    .format("jdbc")
                    .option("url", "myUrl")
                    .option("user", "myUser")
                    .option("password", "myPwd")
                    .option("query", "myQuery")
                    .option("driver", "org.postgresql.Driver")
                    .load();
SparkDataset dataset = new SparkDataset(sparkDataset);
In this example, the project must include a dependency to the PostgreSQL driver:
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.5.1</version>
</dependency>
See all supported options in the official documentation.
Write
Le format JDBC format is not recommended for writing Trevas Datasets (see here)