Bonjour
Dans mon programme, lors du premier lancement, je lance la connexion sur une base de données hsql, jusque là, pas de problèmes, tout marche bien. Mais ensuite, j'initialise cette base de données avec cette méthode :
et là, il me fait une l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 protected void initializeDb(){ Statement statement = null; try { statement = connection.createStatement(); //Création de la table film statement.executeUpdate("CREATE TABLE film " + "(ID INT(11) NOT NULL AUTO_INCREMENT, nom VARCHAR(100) NOT NULL, genre INT(11) NOT NULL, type INT(11) NOT NULL" + ", annee INT(11) NOT NULL, duree INT(11) NOT NULL, state INT(11) NOT NULL, realisateur INT(11) NOT NULL, " + "langue INT(11) NOT NULL, location INT(11) NOT NULL, note INT(11) NOT NULL,INDEX (ID))"); ... } catch (SQLException e) { e.printStackTrace(); } finally{ try { statement.close();} catch (SQLException e) {e.printStackTrace();} } }
Elle pointe sur la ligne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 java.sql.SQLException: Unexpected token in statement [CREATE TABLE film (ID INT(11] at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.executeUpdate(Unknown Source) at jTheque.Fonctions.initializeDb(Fonctions.java:177) at jTheque.GuiFirstStart$1.mouseClicked(GuiFirstStart.java:128) at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Est-ce que vous savez d'ou ca viens ? Y a t'il des limitations avec HSQL ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 statement.executeUpdate("CREATE TABLE film " + "(ID INT(11) NOT NULL AUTO_INCREMENT, nom VARCHAR(100) NOT NULL, genre INT(11) NOT NULL, type INT(11) NOT NULL" + ", annee INT(11) NOT NULL, duree INT(11) NOT NULL, state INT(11) NOT NULL, realisateur INT(11) NOT NULL, " + "langue INT(11) NOT NULL, location INT(11) NOT NULL, note INT(11) NOT NULL,INDEX (ID))");
P.S. J'ai testé cette méthode sur une base de données mysql et elle marche tout à fait bien.
Partager