A. postgres?sslmode=allow
B. postgres?ssl=true&sslmode=allow
C. postgres?ssl=true&sslmode=allow&sslrootcert=E:\\global-bundle.pem
You can also use “Connection String” option where the entire string can be mentioned as
Connection string sample: jdbc:postgresql://<Host>:<Port>/<DB Name>?sslmode=allow
Using User Defined Java Class. Refer below code.
import java.sql.Connection;
import java.sql.DriverManager;
if (first) {
first = false;
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
String jdbcUrl = "jdbc:postgresql://<host>:<port>/dbname?sslmode=allow";
String username = "abc";
String password = "abc";
try {
System.out.println("Connecting to database...");
// Attempt connection
Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
logBasic("Connection successful!");
// Close the connection
conn.close();
logBasic("Connection failed:");
logBasic(e.getMessage());
//logBasic(e.printStackTrace());
}
return true;
}
After adding this we were able to test the connection successfully.