I'm trying to run a script (.sql file) but i have multiples errors since i tried many ways, here's my main sql script:
INSERT INTO `Unity` VALUES (11,'paq',0,'2013-04-15 11:41:37','Admin','Paquete','Paq',0,'2013-04-15 11:41:37','AAA010101AAA',NULL);
INSERT INTO `product` VALUES (11,'chi','USD','chi one',0,'2013-04-15 11:42:13',0,'Admin','Chi name',0.25,0,15,'2013-04-15 11:42:13','AAA010101AAA',NULL);
and here's my main dao code:
@Autowired
private EntityManager em;
@Override
public Integer runSql(String path) {
try {
Archivo archivo = new Archivo();
String strQuery = archivo.readFileText(path);
Query query = em.createNativeQuery(strQuery);
return query.executeUpdate();
} catch (IOException e) {
e.printStackTrace();
return 0; //TODO return false;
}
}
If i run the script with only one Insert it runs ok, but when my script has more than 1 insert i get the following Exception:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO
producto_servicioVALUES (11,'chi','USD','chi one',0,'2013-04-15 11:42:13',0,'' at line 2
Is there a way to run a script file with multiple inserts?
I also tried with BEGIN, and END, and START TRANSACTION AND COMMIT, but with no good results.
Thank you for the help :)