Salut
Voila ça fait un an que j'avais pas utilisé hsqldb avec java et aujourd'hui quand j'ai voulu réessayer j'arrive a créer une table mais j'arrive ni a inséré des données grâce à la commande INSERT et ni a les lire grâce a la commande SELECT enfin bref il y a un an j'avais trouvé la solution on la cherchant sur google je l'avais lu sur un forum dont hélas le topic n'existe plus aujourd'hui bref ils avaient dit que le fichier de la bdd doit être dans le même environnement que le code java a exécuté ou quelque chose comme ça je m'en rappel pas très bien j'ai essayé de me rappeler comment faire mais rien j'arrive pas a lire les donnée je sais que mon explication a l'aire un peu flou alors je vais afficher les codes :
Code pour créer la table
Code pour remplire la table
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
27
28
29
30
31
32
33
34
35 import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class Connect { public static void main(String[] args) { try { Class.forName("org.hsqldb.jdbcDriver").newInstance(); System.out.println("DRIVER OK ! "); Connection connexion = DriverManager.getConnection("jdbc:hsqldb:file:GESTLIB", "khaled", ""); System.out.println("Connection effective !"); Statement state = connexion.createStatement(); state.executeUpdate("CREATE TABLE livres (" + "code_livre INT PRIMARY KEY," + "titre_livre VARCHAR(30)," + "prix_livre INT," + "quantite_livre INT," + "seuil_secutite_livre INT," + "auteur_livre VARCHAR(30)," + "editeur_livre VARCHAR(30)" + ")"); state.close(); } catch (Exception e) { e.printStackTrace(); } } }
quand j'essaye de creer la table livres (la bdd est créée automatiquement magie de hsqldb ) ça marche bien méme que le fichier de la bdd se crée dans le dossier C:\workspace (pour info les fichiers java se trouve dans le dossier C:\workspace\GESTLIB ) mais quand j'essaye de la remplir voila ce qui se passe :
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
27
28
29
30
31
32
33
34 import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class Inserer { public static void main(String[] args) { try { Class.forName("org.hsqldb.jdbcDriver").newInstance(); System.out.println("DRIVER OK ! "); Connection connexion = DriverManager.getConnection("jdbc:hsqldb:file:GESTLIB", "khaled", ""); System.out.println("Connection effective !"); Statement state = connexion.createStatement(); state.executeUpdate("INSERT INTO livres (code_livre," + "titre_livre," + "prix_livre," + "quantite_livre," + "seuil_securtite_livre," + "auteur_livre," + "editeur_livre) VALUES ('1', 'java', '80', '100', '200', 'Dumat', 'eyrolles')" + ""); state.close(); } catch (Exception e) { e.printStackTrace(); } } }
Pouvez vous m'aider svp ?
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 DRIVER*OK*!* Connection*effective*! java.sql.SQLSyntaxErrorException:*user*lacks*privilege*or*object*not*found:*LIVRES ********at*org.hsqldb.jdbc.Util.sqlException(Unknown*Source) ********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*GESTLIB.Inserer.main(Inserer.java:19) Caused*by:*org.hsqldb.HsqlException:*user*lacks*privilege*or*object*not*found:*LIVRES ********at*org.hsqldb.error.Error.error(Unknown*Source) ********at*org.hsqldb.error.Error.error(Unknown*Source) ********at*org.hsqldb.SchemaManager.getTable(Unknown*Source) ********at*org.hsqldb.ParserDQL.readTableName(Unknown*Source) ********at*org.hsqldb.ParserDQL.readSimpleRangeVariable(Unknown*Source) ********at*org.hsqldb.ParserDML.compileInsertStatement(Unknown*Source) ********at*org.hsqldb.ParserCommand.compilePart(Unknown*Source) ********at*org.hsqldb.ParserCommand.compileStatements(Unknown*Source) ********at*org.hsqldb.Session.executeDirectStatement(Unknown*Source) ********at*org.hsqldb.Session.execute(Unknown*Source) ********...*3*more
Cordialement, montis
Partager