B4J Question B4j Sqlite missing write permission?

gezueb

Active Member
Licensed User
Longtime User
I have made an B4j programm that reads and writes into a local sqlite database. The database is located in the path c:/sql in a windows 10 installation.
The program works perfectly when compiled and executed in the IDE. However, it fails to insert data into the sql database (without exception) when built as a package.
I tried to execute it with adminstrators rights, to no avail. The path c:/sql is not write protected in my installation.
Thanks for help
 

DonManfred

Expert
Licensed User
Longtime User
run the debug.bat and look for any error
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
If I run the bat file this in itself says "file not found":
C:\WINDOWS\system32>cd bin
Das System kann den angegebenen Pfad nicht finden.

C:\WINDOWS\system32>java.exe @release_java_modules.txt -m b4j/b4j.andromedar.main
Fehler: Hauptklasse @release_java_modules.txt konnte nicht gefunden oder geladen werden

C:\WINDOWS\system32>pause
Drücken Sie eine beliebige Taste . . .

I think the problem is related to the rather complicated permissions of Windows 10. I may move the dbase to some other location but since I would like to produce a package, it is difficult to find a hard coded path that fits all users.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Why are you running it from Windows\system32? This is not the correct place to put apps.

I may move the dbase to some other location but since I would like to produce a package, it is difficult to find a hard coded path that fits all users.
Not at all.

Use XUI.DefaultFolder.
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
Erel, I am not running the app from windows\system32. I guess the cmd.exe runs from there that executes the bat file.
I did what you recommended and planted my database into the default uix folder.
But the symptoms are still the same: The app works perfectly when run from the b4j IDE, it fails to add to the SQL database when run as a package, regardless of administrator rights.
One of the statements that does not work is the one here:
B4X:
                SQL1.ExecNonQuery2("INSERT INTO Kurse VALUES (?,?,?)",Array As Object(Nr,price,Heute))
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
I think we are barking up the wrong tree. I just followed your advice to run the run_debug.bat and that seems to finally call the cmd console. But that is not my main problem, I just dont know why there's a difference in executing a b4j app either from the IDE or as a packed .exe.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Ok, let's start from the beginning:

1. You've created a standalone UI package via "project -> Build standalone package"? (yes/no)
2. You click on the generated *.exe file inside the generated build folder (yes/no)
3. What is the exact path of the generated build folder?
4. Is the development root folder (where your source code is) different from the build folder? Did you move the build folder? (I assume yes)
5. What is the exact path & filename of the database? "SQLite.InitializeSQLite(...)"
6. Could an antivir-sw prevent the start?

PS: I have some B4J apps in production on WIN10 and WIN2016 Server machines without any problems...
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
1. yes
2. yes (also as a link, but no difference in behaviour)
3. the path to the .exe is a subfolder of the development root folder. /object/temp/build
4. No. And the build folder is not moved. The root folder is in my documents, so I have full read/write/delete access on it.
5 the path is as recommended by erel the uix default folder (for me: C:\Users\Georg\AppData\Roaming\Boerse
6. No. The funny thing is that it starts alright, reads tables but simple does not insert anything - no exception, no error message. Obviously, I cannot log anything when run as a package- It behaves like (silent) write protect.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Strange. Can you try a SQLite example from the forum? (like my "millions of rows" example). Does it work? Before: Can you write simple files to that folder? Should be the same as SQlite is a simple file. Maybe your Insert statements are faulty.
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
Yes, I can write a simple file into the said path. There's a backup function in my app that makes a copy of the database and this works okay.
What I will try is convert the SQL statements into the async form and WAIT FOR the results before proceding. Maybe there's the snag that the
packaged version is faster than the compiled one.
However, today I am out so I will let you know about the results tomorrow.
Thanks to you all for your advice,
Georg
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
It was me that was barking up the wrong tree, sorry my friends! My suspicion is now that the preceding Httpjob fails only when executed as package, returning no results. Thus, its not the insert into the SGQlite thats wrong. I will keep you informed when I found out the problem with the Htttpjob. Anyway, thanks to you all and so long, Georg
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
The culprit is indeed the Httpjob and not the following sql insert:
B4X:
        Dim job As HttpJob
        job.Initialize("",Me)
        Dim price,price As Double
        job.Download(RS.GetString("SearchFor"))
        Wait For (job) JobDone(job As HttpJob)
        If Not(job.Success) Then
            Dim message As String
            message = job.ErrorMessage
            MsgBox.Show("httpjob failed"&message,"")
        End If
Fails with the following message:
javax.net.ssl.protokollexception connection reset

but only as package, not when compiled in the IDE. So SQLite is working as advertised! I will come back to you all when I found out what cause this.
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
Indeed, Erel, this helps!
???
Now it works like a charm. Thanks to you and KMatle and DonManfred!
 
Upvote 0
Top