How to close all connections in HSQLDB (also prevents a locking defect) Come chiudere tutti i collegamenti in HSQLDB (inoltre impedisce un difetto di bloccaggio)
I have noticed that despite closing all connections and exiting a standalone HSQLDB database, at least one connection still remains open. Ho notato che, nonostante la chiusura di tutti i raccordi e uscendo da una banca dati standalone HSQLDB, almeno una connessione è ancora aperta.
The defect is manifested in HSQLDB 1.7.3 and HSQLDB 1.8.0 RC 8. Il difetto si manifesta in HSQLDB 1.7.3 e la 1.8.0 HSQLDB RC 8.
If you compile and run the sample code below, it will run fine for the first time. Se si compilare ed eseguire il codice di esempio qui di seguito, viene eseguito il comando ammenda per la prima volta. Second time (if it is run immediately after the first time say within 2-3 seconds after completion of first execution) it fails everytime citing a database locked exception! Seconda volta (se si tratta di lanciare immediatamente dopo la prima volta dire nel giro di 2-3 secondi dopo il completamento della prima esecuzione) che non sempre citando una banca dati bloccato eccezione!
Filed under Elencato sotto How To Come , Java Software Software Java , RDBMS | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |




March 11th, 2005 at 10:40 am 11 Marzo 2005 alle 10:40 am
No. This is not a defect. No Questo non è un difetto.
I did an extensive analysis and wrote the current hsqldb lock file and priority timer queue implementation: I disagree with your analysis. Ho fatto una vasta analisi e ha scritto l'attuale HSQLDB file di lock timer e di priorità della coda di attuazione: sono d'accordo con la tua analisi.
HSQLDB is now like Oracle or MySQL, et al: to correctly shut down the database, you must explicitly issue a command as an admin user. HSQLDB è ora come Oracle o MySQL, et al: a chiudere correttamente il database, è esplicitamente emettere un comando come un utente amministratore. (”SHUTDOWN …”). ( "SHUTDOWN…").
The main difference is that, unlike Oracle/MySQL, etc., which are fairly rigidly “single installation per machine/release version/data file set” products, it has been observed much more likely that maybe serveral HSQLDB installations/running JVM instances on a machine and each may attempt to access a specific database file set. La principale differenza è che, a differenza di Oracle / MySQL, ecc, che sono abbastanza rigido "unico impianto per macchina / versione / file di dati di impostare" prodotti, si è osservato molto più probabile che forse serveral HSQLDB impianti / JVM in esecuzione su casi una macchina e ognuno può tentare di accedere ad uno specifico file di database.
That is, we have the problem msaccess had (has?), when the database files were (are?) on a network drive and accessed by several different client machines simultaneously. Che è, abbiamo il problema msaccess era (è?), Quando il file di database sono stati (sono?) Su un'unità di rete e accedere da diverse macchine client simultaneamente.
But our problem is even more likely to occur, because Java does not provide a shared-mem/ipc ODBC connection manager that allows multiple JVM processes to acccess the same local database file (unless you use the JDBC/ODBC driver, which is not available to type 4 implementations, without writing JNI layer) Ma il nostro problema è ancora più probabile che si verifichi, perché Java non fornisce una shared-mem/ipc ODBC Connection Manager che consente a più processi di JVM accedere allo stesso file di database locale (a meno che non si usa il JDBC / ODBC driver, che non è disponibile tipo 4 a implementazioni, senza scrivere JNI layer)
Anyway, if you abort the JVM (ctrl-c), kill, etc., or for any other reason the JVM dies abruptly, does a halt() (or even exit() on older JDKS where deleteOnExit is not available), then sure… the .lck file does not get deleted. In ogni modo, se si interrompere la JVM (Ctrl-C), uccidere, ecc, o per qualsiasi altra ragione la JVM muore improvvisamente, non una battuta d'arresto () (o anche l'uscita () su di età JDK deleteOnExit dove non è disponibile), quindi certo…. lck file non avere soppresso.
In the next release or so, we will auto-detect availability of shutdownHook and add handler there, but this still will not help of true JVM abends. Nella prossima versione o così, noi rilevare automaticamente la disponibilità di shutdownHook e aggiungere gestore, ma questo ancora non contribuirà di vera JVM abends.
But back to the point: if the .lck file does not get deleted, then there’sa 10 second buffer zone because the lock file is touched at 10 second intervals. Ma ritornare al punto: se l'. Lck file non avere eliminato, quindi c'è un 10 secondi zona cuscinetto perché il file di lock è toccato a intervalli di 10 secondi.
I chose this number so that in cases where there is really heavy CPU and disk usage going on, there’sa fairly safe buffer zone: Java and most operating systems do not do really accurate timing, especially under high load. Ho scelto questo numero in modo che nei casi in cui vi è davvero pesante della CPU e del disco in corso, c'è abbastanza sicuro zona cuscinetto: Java e la maggior parte dei sistemi operativi non fare veramente preciso calendario, soprattutto sotto carico elevato. Just think about the case of a really high res, high frame-rate video with high bit-rate audio on a file) does not constitute an OS-enforced cross-process lock on the file. Basta pensare al caso di un realmente ad alta risoluzione, alto tasso di frame-video con elevato bit-rate audio su di un file), non costituisce un sistema operativo-forzata tra processi di blocco sul file.
April 4th, 2005 at 3:30 pm 4 aprile 2005 a 3:30 pm
@Campbell @ Campbell
Thanks for your detailed insight into this issue. Grazie per il tuo ottenere una visione dettagliata in questione.
As you can see from my Come potete vedere dal mio code above codice di cui sopra that I am normally closing my connection to the database. che sono di norma di chiusura la mia connessione al database. I had opened the database as a single user from my application (in other words not as a server). Mi aveva aperto il database come un singolo utente dalla mia domanda (in altre parole, non come un server). So the rules of server requiring a shutdown shouldn’t really be applicable here. Così le regole del server che richiedono un arresto non dovrebbe davvero essere applicabili qui.
I am with you wrt. Io sono con voi WRT. your locking logic in a server scenario. il tuo blocco logica in un server di scenario. However as a single user closing the connection should be sufficient cue to release any lock to the database. Tuttavia, come un singolo utente di chiudere il collegamento dovrebbe essere sufficiente spunto per liberare i lock al database.
I think most use cases to HSQLDB is in single user (non-server) mode. Penso che la maggior parte dei casi l'uso di HSQLDB è in singolo utente (non-server). Often we use it to load test cases for junit tests etc. In these cases ability to rapidly restart is a great benefit. Spesso abbiamo usato per caricare i casi di prova per i test ecc JUnit In questi casi la capacità di riavviare rapidamente è un grande vantaggio.
What do you think? Che cosa ne pensi?
April 6th, 2005 at 1:39 am 6 aprile 2005 alle 1:39 am
Hello, Ciao,
i have the same problem. ho lo stesso problema.
You’ve wrote: Hai scritto:
***********************
you must explicitly issue a command as an admin user. è esplicitamente emettere un comando come un utente amministratore. (”SHUTDOWN …”). ( "SHUTDOWN…").
***********************
Can you please give me a small code example of that shutdown procedure? Potresti darmi un piccolo esempio di codice che la procedura di arresto?
Thank you Grazie
Stefan
April 6th, 2005 at 2:09 pm 6 aprile 2005 a 2:09 pm
@Stefan Stefan @
stmt.executeUpdate(”SHUTDOWN”); stmt.executeUpdate ( "Shutdown");
where stmt is the java.sql.Statement you have created earlier from HSQLDB java.sql.Connection. stmt dove è il java.sql.Statement che avete creato in precedenza da HSQLDB java.sql.Connection.
January 28th, 2006 at 11:57 pm 28 gennaio 2006 a 11:57 pm
Nice site and ur information is nice. Nizza sito e ur informazioni è piacevole.
i appriciate this. i appriciate questo.
Jakkireddy
April 1st, 2006 at 12:49 am 1 ° aprile 2006 alle 12:49 am
But what should I do when I debug with my IDE and terminate abruptly my application? Ma che cosa devo fare quando ho debug con il mio IDE e chiudere bruscamente la mia domanda? This will lead to an not terminated database connection. Ciò porterà ad un non risolto connessione al database.
Is there any way to get over this effect? Esiste un modo per superare questo effetto?
April 1st, 2006 at 8:32 am 1 ° aprile 2006 a 8:32 am
The file may get corrupted. Il file può arrivare danneggiato. At worst you have to manually truncate it. Nella peggiore delle ipotesi dovete manualmente troncare.