0
statement2=Myconn.prepareStatement("SET @rank:=0; update entretien "+
                    " set numero_entretien=@rank:=@rank+1 where vehicule_id=?;");
statement2.setInt(1,1);
statement2.executeUpdate();

This query works on mysql workbench , but it doesn't work in java

I have latest MySQL and JDBC version ,I think that the problem is maybe in the ";" that follow @rank:=0 ?

Sierra
  • 11
  • 3

1 Answers1

0

You're right. By default it is not possible to execute more than one query per statement. But you can enable multiple query support by appending ?allowMultiQueries=true to the jdbc connection string.

You can find more details in this SO answer.

Community
  • 1
  • 1
streetturtle
  • 5,472
  • 2
  • 25
  • 43