I set up a connection from Anypoint Studio 7.4 to Database and I'm using postgresql version 42.2.1.
Error Response:
org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source
Caused by: org.mule.extension.db.api.exception.connection.ConnectionCreationException: Could not obtain connection from data source
Caused by: org.mule.runtime.extension.api.exception.ModuleException: java.sql.SQLException: Cannot get connection for URL jdbc:postgresql://myhost:port/mulesoft : No suitable driver found for jdbc:postgresql:myhost:port/mulesoft
Caused by: java.sql.SQLException: Cannot get connection for URL jdbc:postgresql:myhost:port/mulesoft : No suitable driver found for jdbc:postgresql:myhost:port/mulesoft
at org.mule.extension.db.internal.domain.connection.JdbcConnectionFactory.createConnection(JdbcConnectionFactory.java:57)
at org.mule.extension.db.internal.domain.connection.DbConnectionProvider.connect(DbConnectionProvider.java:139)
at org.mule.extension.db.internal.domain.connection.DbConnectionProvider.connect(DbConnectionProvider.java:71)
You need to either use the configure button or manually add a Postgresql JDBC driver dependency to the pom.
Example pom:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.9</version>
</dependency>
You also need to add the driver groupId and artifactId to the shared libraries section of the Mule Maven Plugin in the pom, so it can be accessed by the DB connector.
Example:
...
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>3.3.5</version>
<configuration>
<sharedLibraries>
<sharedLibrary>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</sharedLibrary>
</sharedLibraries>
</configuration>
</plugin>
</plugins>
If the configurations are correct, check that the database name is present in the URL. For example in the JDBC URL jdbc:postgresql:myhost:port/mulesoft
, the /mulesoft
at the end is the database name. If it is missing it can cause the same error.