I´m trying to connect to an Azure Mysql database server to create a table from a Dataframe in Azure Synapse with Spark.
I have this url and this properties All variables like jdbcXYZ are fulled with the correct values from the database
import java.util.Properties
val jdbc_url = s"jdbc:mysql://${jdbcHostname}:${jdbcPort}/database=${jdbcDatabase};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=60;"
val connectionProperties = new Properties()
connectionProperties.put("user", s"${jdbcUsername}")
connectionProperties.put("password", s"${jdbcPassword}")
And i try to write to the database with
spark.table("tabletemp").write.mode("append").jdbc(jdbc_url, "table", connectionProperties)
I also tried
df.write.format("jdbc").mode("append").option("url", jdbc_url).option("dbtable", jdbcDatabase).option("user", jdbcUsername).option("password", jdbcPassword).save()
And i´m always receiving the same error
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
Do you know how to solve it? Thanks in advance