Android Question Random error with Sqlite SQLCipher

Discussion in 'Android Questions' started by rscheel, Jul 6, 2017.

  1. rscheel

    rscheel Well-Known Member Licensed User

    I have the following error with the library SQLCipher 1.40 this I use to initialize the encrypted BD SQLite, for the cursor I used the SQL library v1.50, I understand that the error is the cursor, I do not know how to solve it. Any help would greatly appreciate them.

    Code:
    java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCursor.finalize() timed out after 10 seconds
        at java.lang.Object.wait(Native Method)
        at java.lang.Thread.parkFor$(
    Thread.java:1220)
        at sun.misc.Unsafe.park(Unsafe.java:
    299)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:
    158)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:
    810)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:
    844)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:
    1173)
        at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:
    196)
        at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:
    257)
        at net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:
    490)
        at net.sqlcipher.database.SQLiteProgram.close(SQLiteProgram.java:
    294)
        at net.sqlcipher.database.SQLiteQuery.close(SQLiteQuery.java:
    136)
        at net.sqlcipher.database.SQLiteCursor.close(SQLiteCursor.java:
    510)
        at net.sqlcipher.database.SQLiteCursor.finalize(SQLiteCursor.java:
    595)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:
    202)
        at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:
    185)
        at java.lang.Thread.run(
    Thread.java:818)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Is it possible that you started a transaction and never ended it?
     
  3. rscheel

    rscheel Well-Known Member Licensed User

    I think in this case I start one and did not finish it, something happens if I remove the BeginTransaction?

    Code:
    Sub ObtenerMantencionesAbiertas
        Id_Mantencion = 
    0
        ModConn.s.BeginTransaction
        ModConn.c = ModConn.s.ExecQuery(
    "SELECT m.*, (SELECT t.mecanico FROM mecanico t WHERE t.id_mecanico = m.id_mecanico) mecanico FROM eventos m WHERE m.sync = 0 AND m.codigo_qr = '"&ValorQr&"' AND id_tipoevento = -1 ;")
        
    If ModConn.c.RowCount <> 0 Then
            
    For i = 0 To ModConn.c.RowCount-1
                ModConn.c.Position = i
                Id_Mantencion = ModConn.c.GetInt(
    "id_evento")
                ID_QrMantencion = ModConn.c.GetInt(
    "codigo_qr")
                Fecha_Creacion_Mantencion = ModConn.c.GetString(
    "fecha_inicio")
                Mecanico_Encontrado = ModConn.c.GetString(
    "mecanico")
            
    Next
           
            Msgbox2Async(
    "Mantención encontrada:"Chr(13)&Chr(10)&Chr(13)&Chr(10) & _
                        
    "Mecanico        : "&Mecanico_Encontrado& Chr(13)&Chr(10) & _
                        
    "Equipo                    : "&ID_QrMantencion& Chr(13)&Chr(10)& _
                        
    "Iniciado                : "&Fecha_Creacion_Mantencion& Chr(13)&Chr(10) & _
                        
    "Duración            : "&"?"Chr(13)&Chr(10)&Chr(13)&Chr(10)& _
            
    "Desea cerrar?""Alerta""Si""""Cancelar"LoadBitmap(File.DirAssets, "warning.png"), False)
            
    Wait For Msgbox_Result (Result As Int)
            
    If Result = DialogResponse.POSITIVE Then
                GuardaActualizaMantencion
            
    End If

            
    If Result = DialogResponse.NEGATIVE Then
                
    Activity.Finish
            
    End If
        
    Else
            DialogMecanico
        
    End If
        ModConn.c.Close
        ModConn.s.TransactionSuccessful
        ModConn.s.EndTransaction
    End Sub
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You don't need to create a transaction for select queries.
     
    rscheel likes this.
  5. rscheel

    rscheel Well-Known Member Licensed User

    OK thanks.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice