I'm using JDBC to make my Java application handle SQL statements to my MySQL database. For some reason it can't do multiple insert statements in one executeUpdate() method.
My code looks like this:
PreparedStatement statement = connection().prepareStatement(sql);
boolean success = statement.executeUpdate() > 0;
if (doClose)
closeConnection();
return success;
where sql is a string of the SQL statement.
It tells me there is a sql syntax error, where the new insert statement begins.
The SQL looks like this:
INSERT INTO subscriptions(user_id,`status`,subscription_type,offer_type,offer_expires,offer_effect,card_id)
VALUES (18,'ACCEPTED','FREEMIUM',NULL,NULL,NULL,NULL);
INSERT INTO contact_informations(user_id,email,first_digits,phone_number,phone_is_mobile,street,floor,postal,city,country_title,country_indexes)
VALUES (18,'cool@gmail.com',45,57104998,false,'Nørrevang 15','5. th.','2528','Holbæk','Tyskland','DE');
It works perfectly, when I split the two statement, but in my MySQL workbench editor, it handles the statement in one take.
Is there a way to perform both in one JDBC statement?