oui oui rectifies avec
EricCode:ScriptRunner sr = new ScriptRunner(cn)
Version imprimable
oui oui rectifies avec
EricCode:ScriptRunner sr = new ScriptRunner(cn)
Alors, avec lej'ai une erreur directement :Code:sr.setSendFullScript(true)
et sans l'envoi total du script j'ai ceci :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Error executing: START TRANSACTION; INSERT into ahiweb.utilisateur VALUES ('955', '55', '117', 'Tata', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ); INSERT into ahiweb.utilisater VALUES ('956', '55', '117', 'Tutu', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ); UPDATE ahiweb.utilisateur SET nom = 'AANNDDAANNSSOONN' WHERE id = '284'; CREATE TABLE `ahiweb`.`tabletest` ( `idtabletest` INT NOT NULL AUTO_INCREMENT COMMENT '', `nomtabletest` VARCHAR(45) NULL COMMENT '', `numerotabletest` INT NULL COMMENT '', `villetabletest` INT(10) UNSIGNED NULL COMMENT '', PRIMARY KEY (`idtabletest`) COMMENT '', INDEX `FKTest_idx` (`villetabletest` ASC) COMMENT '', CONSTRAINT `FKTest` FOREIGN KEY (`villetabletest`) REFERENCES `ahiweb`.`adr` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); . Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ahiweb.utilisateur VALUES ('955', '55', '117', 'Tata', 'Titi', 'toto' at line 3
:/Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 START TRANSACTION INSERT into ahiweb.utilisateur VALUES ('955', '55', '117', 'Tata', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ) INSERT into ahiweb.utilisater VALUES ('956', '55', '117', 'Tutu', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ) Error executing: INSERT into ahiweb.utilisater VALUES ('956', '55', '117', 'Tutu', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ) . Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ahiweb.utilisater' doesn't exist UPDATE ahiweb.utilisateur SET nom = 'AANNDDAANNSSOONN' WHERE id = '284' CREATE TABLE `ahiweb`.`tabletest` ( `idtabletest` INT NOT NULL AUTO_INCREMENT COMMENT '', `nomtabletest` VARCHAR(45) NULL COMMENT '', `numerotabletest` INT NULL COMMENT '', `villetabletest` INT(10) UNSIGNED NULL COMMENT '', PRIMARY KEY (`idtabletest`) COMMENT '', INDEX `FKTest_idx` (`villetabletest` ASC) COMMENT '', CONSTRAINT `FKTest` FOREIGN KEY (`villetabletest`) REFERENCES `ahiweb`.`adr` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
Marvin.
oui c´est normal, tu as:
etCode:into ahiweb.utilisater
ericCode:into ahiweb.utilisateur
Désolé d'envoyer un autre message sans attendre ta réponse, mais je trouve quelque chose d'étrange là ...
J'essaye de catcher une erreur sur mon bloc imbriqué dans le try/catch mais impossible ! JAMAIS on ne rentre dans le catch peu importe l'exception que je souhaite catch...meme avec Exception e qui est sensé attraper n'importe quelle exception !
Code :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class Main { public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException{ //FenetreTest f = new FenetreTest(); //f.setVisible(true); String monScript = "script.sql"; try { Class.forName("com.mysql.jdbc.Driver"); Connection cn = DriverManager.getConnection("jdbc:mysql://localhost/ahiweb", "root", "P@ssw#rd"); ScriptRunner sr = new ScriptRunner(cn); sr.setAutoCommit(false); Reader r = new BufferedReader( new FileReader(monScript)); //sr.setSendFullScript(true); sr.runScript(r); } catch(Exception e) { System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!"); } } }
Oups, désolé .. L'erreur de nom de tableétait voulu, j'essayé de catch les exceptions (message précédent).Code:utilisater
En rétablissant la bonne orthographe, cela fonctionne sans le setSendFullScript mais lorsque j'envoi le script entier, avec ceci, j'ai toujours cette erreur :Code:sr.setSendFullScript(true);
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Error executing: START TRANSACTION; INSERT into ahiweb.utilisateur VALUES ('955', '55', '117', 'Tata', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ); INSERT into ahiweb.utilisateur VALUES ('956', '55', '117', 'Tutu', 'Titi', 'toto', 'toto', '2', '1', 'toto@gmail.com', '1', '0656565656', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '', '2012-01-02 00:00:00', '2012-01-02 00:00:00', '0', '0', '0', '0', '0' ); UPDATE ahiweb.utilisateur SET nom = 'AANNDDAANNSSOONN' WHERE id = '284'; CREATE TABLE `ahiweb`.`tabletest` ( `idtabletest` INT NOT NULL AUTO_INCREMENT COMMENT '', `nomtabletest` VARCHAR(45) NULL COMMENT '', `numerotabletest` INT NULL COMMENT '', `villetabletest` INT(10) UNSIGNED NULL COMMENT '', PRIMARY KEY (`idtabletest`) COMMENT '', INDEX `FKTest_idx` (`villetabletest` ASC) COMMENT '', CONSTRAINT `FKTest` FOREIGN KEY (`villetabletest`) REFERENCES `ahiweb`.`adr` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); . Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ahiweb.utilisateur VALUES ('955', '55', '117', 'Tata', 'Titi', 'toto' at line 3