B4J Question sqlite and linux

ivanomonti

Expert
Licensed User
Longtime User
I have problems with reading db sqlite in linux!

how can i solve :-(
 

ivanomonti

Expert
Licensed User
Longtime User
Schermata del 2019-02-05 16-12-43.png
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
in windows everything works fine, when I start the jar I read if there is a folder and if it does not exist, then open the db sqlite and I query and I repeat on windows everything ok, on linux I can not write the folder and read its content if it hesitates and when I query it gives me an error

Load record sqlite

B4X:
Public Sub reload
    
    TableView1.Items.Clear
    Try
    '-------> load record agent <------------------------------
    ListAgent.Initialize
    sql1.InitializeSQLite(File.DirApp, "datasqlite.db", True)
    RS = sql1.ExecQuery("select * from data2")
    Do While RS.NextRow
        Dim Row() As Object = Array (RS.GetString("nome"), RS.GetString("cognome"), RS.GetString("phone"), RS.GetString("email"),  RS.GetString("code"))
        ListAgent.Add(Row)
    Loop
    RS.Close
    
    '-------> load record client <------------------------------
    sql1.InitializeSQLite(File.DirApp, "datasqlite.db", True)
    RS = sql1.ExecQuery("select * from data1")
    Do While RS.NextRow
        
    '----------------> append note record <--------------------------------
        Dim RSR As ResultSet
        RSR = sql1.ExecQuery("select * from data3 WHERE relation='" & RS.GetString("phone") & "';")
        Do While RSR.NextRow
            Dim Row() As Object = Array (RS.GetString("nome"), RS.GetString("cognome"), RS.GetString("indirizzo"), RS.GetString("citta"), RS.GetString("phone"),  RS.GetString("email"),RSR.GetString("radio"), RSR.GetString("note"), RSR.GetString("agent"))
        Loop
    '------------------> public record into tableview <-------------------------------------------
        TableView1.Items.Add(Row)
    Loop
    
        RS.Close
    Catch
        Log(LastException)
        fx.Msgbox(MainForm,LastException,"Error try")
    End Try
End Sub

load menu and create menu plugins

B4X:
Sub addmenu(form As Form)
    
    Dim mb As MenuBar
    mb.Initialize("")
    form.RootPane.AddNode(mb, 0, 0, 0,0)
    
    Dim age As Menu
    age.Initialize("Agenti", "")
    
    Dim data As Menu
    data.Initialize("Database", "")
    
    Dim plugins As Menu
    plugins.Initialize("Moduli", "")
    
    mb.Menus.Add(age)
    mb.Menus.Add(data)
    mb.Menus.Add(plugins)
    
    Dim mm As MenuItem
    mm.Initialize("Agenti", "MenuBar1")
    age.MenuItems.Add(mm)
    
    Dim mm As MenuItem
    mm.Initialize("Ricarica", "MenuBar1")
    data.MenuItems.Add(mm)
    
    If File.IsDirectory(File.DirApp,"plugins") = False Then
        File.MakeDir(File.DirApp,"plugins")
    End If
    
    Dim l As List = File.ListFiles(File.Combine( File.DirApp,"plugins"))
    
    For i = 0 To l.Size - 1
        If isDir(l.Get(i)) = False Then
            Dim nameapp,urlapp As String
            nameapp = l.Get(i)
            nameapp = nameapp.Replace(".jar","")
            urlapp = File.Combine(File.Combine( File.DirApp,"plugins"),l.Get(i))
            Dim mm As MenuItem
            mm.Initialize(nameapp, "MenuBarplugins")
            mm.Tag = urlapp
            plugins.MenuItems.Add(mm)
        End If
    Next
    
End Sub
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
1 I'm on Linux and I'm throwing a single jar error and the one recovered with exception
2 folder with jar + db.sqlite + folder plugin
3 ok this is my mistake

Cattura.PNG


windows 10pro perfect

Cattura2.PNG
 
Last edited:
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
I'm sorry but I cannot help you as you are not answering my questions...

I send you a copy of the draft basted, maybe you can see where I'm wrong
 

Attachments

  • DataBase-2019.zip
    180.5 KB · Views: 145
Upvote 0

OliverA

Expert
Licensed User
Longtime User
One huge problem is that you are opening the DB multiple times without closing it. Don't do that. You should only have to open the DB once, unless there is some other reason why you need to open/close the DB constantly.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Call initializedb once in AppStart and comment it out everywhere else it is called (and it is in a lot of places).
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Call initializedb once in AppStart and comment it out everywhere else it is called (and it is in a lot of places).

true what you say, although many are under control if db and is not open open it, I have eliminated all open db useless, but the fact remains that on linux I can not open the db
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
The database works fine here.

I've changed your code to:
B4X:
public Sub initializedb
   Log(File.DirApp)
   sql1.InitializeSQLite(File.DirApp, "datasqlite.db", False)
End Sub

I then copied the database file to that path. I guess that you haven't copied it and are opening an empty database each time.


same error, invalid or non-existent path, the database is present in the same directory but not found, I installed slqite for linux and the database is perfect, I launched the path with the terminal and find it, I put the database free in writing and reading, but I always have the same error.
Linux ubuntu 14.04 :-(
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Will need some more info: path of program location, path of database location, rights of program, rights of database, rights of directory containing program and database (rights via ls -l). JDK version used to create program, JRE/JDK that is running program. How are you getting the database to the location?
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Will need some more info: path of program location, path of database location, rights of program, rights of database, rights of directory containing program and database (rights via ls -l). JDK version used to create program, JRE/JDK that is running program. How are you getting the database to the location?

all the paths and rights are right reading in the registry of the system gives me all the right path, but I do not see it, my pc is not mine and therefore I can not give you more information if not those that the client passes to me.
 
Upvote 0
Top