Bonjour tous le monde,
je cherche depuis plusieurs jours comment verrouillé une table dans HSQL .
c'est pas la même syntaxe que SQL .
j'ai utilisé la syntaxe :
mais sa ne marche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part LOCK TABLE MaTable Read
voici mon code
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
36
37
38
39 public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException, SAXException, IOException, ParserConfigurationException { ResultSet resultat = connexion("SELECT nom FROM Banque WHERE num_compte = 1987 " ); if(resultat.next()) { String nom=resultat.getString("nom" ); System.out.println(nom); } resultat=connexion("LOCK TABLE Banque Read" ); resultat = connexion("SELECT nom FROM Banque WHERE num_compte = 1987 " ); if(resultat.next()) { String nom=resultat.getString("nom" ); System.out.println(nom); } else System.out.println("Lock" ); } //====================================================== public static ResultSet connexion( String requete) { ResultSet resultat=null; try { System.out.println(requete); Class.forName("org.hsqldb.jdbcDriver" ).newInstance(); Connection connexion = DriverManager.getConnection("jdbc:hsqldb:file:C:\\mydatabases\\BDD_Banque", "sa", "" ); Statement st = connexion.createStatement(); resultat = st.executeQuery(requete); //Sauvegarde et fermeture de la connexion: st.executeQuery("SHUTDOWN" ); st.close(); connexion.close() ; }catch (Exception ex1) { System.out.println("Exeption >>>>> connexion()" ); ex1.printStackTrace(); } return resultat; }
voila ce qui est écrie dans la FAQ HSQL
LOCK TABLE
lock table statement
<lock table statement> ::= LOCK TABLE <table name> { READ | WRITE} [, <table name> { READ | WRITE} ...]}
In some circumstances, where multiple simultaneous transactions are in progress, it may be necessary to ensure a transaction consisting of several statements is completed, without being terminated due to possible deadlock. When this statement is executed, it waits until it can obtain all the listed locks, then returns. The SQL statements following this statements use the locks already obtained (and obtain new locks if necessary) and can proceed without waiting. All the locks are released when a COMMIT or ROLLBACK statement is issued. Currently, this command does not have any effect when the database transaction control model is MVCC.
Example 3.3. Locking Tables
LOCK TABLE table_a WRITE, table_b READ
merci pour votre aide c'est très urgent.
Partager