I've an Azure function app which has a timer trigger function written in Java. I need to connect to PostgreSQL which is deployed on one of the Azure VMs(not using Managed Postgres here).
My code :
import java.sql.*;
public class MyFunction {
public static final String DB_URL = "jdbc:postgresql://<host>:<port>/<dbName>";
public static final String DB_USER = "<dbUser>";
public static final String DB_PASSWORD = "<dbPassword>";
@FunctionName("timerTrigger")
public void timerTrigger(@TimerTrigger(name = "timerTriggerFunc", schedule = "0 */30 * * * *")
String timerInfo, ExecutionContext context) {
Connection connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
connection.setAutoCommit(false);
}
}
When I run this function, its throwing the following exception :
[11/29/2019 10:42:24] java.sql.SQLException: No suitable driver found for jdbc:postgresql://<host>:<port>/<dbName>
[11/29/2019 10:42:24] at java.sql.DriverManager.getConnection(DriverManager.java:689)
[11/29/2019 10:42:24] at java.sql.DriverManager.getConnection(DriverManager.java:247)
Please help resolving this. I went through other questions in stack overflow and browsed, but didn't get my use case elsewhere.
