1

I have a dataframe :

+------------+-------+-------------------+-----------+---+------+--------------------+-----------+
|   id_alerte|id_type|      tracking_time|ID_tracking|vue|    id|         observation|id_vehicule|
+------------+-------+-------------------+-----------+---+------+--------------------+-----------+
|188978561024|      9|2020-02-19 09:20:54|  900100393|  0|100491|LE VEHICULE A ARR...|     997801|
+------------+-------+-------------------+-----------+---+------+--------------------+-----------+

My database table :

+------------------+-------------+
|id_alertePrimaire | int(11)     |
+------------------+-------------+      
|  id_alerte       | int P_K     |
|  id_type         | int(11)     |      
| dateAlerte       | timestamp   |          
| id_tracking      | bigint(20)  |                  
| vue              | tinyint(1)  |          
| id_alert_prog    | int(11)     |              
| observation      | varchar(255)|          
| id_vehicule      |  int(11)    |
+------------------+-------------+              

I want to save this record on a MaySQL table

The code I'm using is :

data.write().format("jdbc").option("url", "myurl")
                             .option("driver", "com.mysql.jdbc.Driver")
                             .option("dbtable", "alerte").option("user", "root").option("password", "").mode("append");

I get no error but nothing is added to the database table

If you have any idea I would be very thankful

1 Answer 1

2

You are passing string "myurl" string instead of variable value mysql.

Try with myurl in option (or) keep your jdbc url as hard coded <jdbc:mysql>...

data.write().format("jdbc").option("url", myurl)
                             .option("driver", "com.mysql.jdbc.Driver")
                             .option("dbtable", "alerte").option("user", "root").option("password", "").mode("append");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.