B4J Question Mac error

roberto64

Active Member
Licensed User
Longtime User
Hi, who can help me? I made a program with a sqlite database, I created two files with "B4JPackager11" one for windows and another for mac, in windows and everything works once I run the "exe" everything ok, instead with the mac but from the following error once I run the program with "run_command", I state that I have already updated "sqlite_jdbc_3.30.1.jar" and I inserted when I open the db the line "sql1.ExecNonQuery (" PRAGMA journal_mode = wal ")", use the sdk 11.0.1 of java for both windows and for mac, in fact I tell you that by bringing the program only compiled with b4j precisely the executable "JAR" it from windows that from mac does not start at all, in the two machines both java 1.8 are installed . Has anyone had these problems ?. secondly does anyone know how to start on mac without run-command?
Regards
java.sql.SQLException: [SQLITE_NOTADB] File opened that is not a database file (file is encrypted or is not a database)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NestedDB.prepare(NestedDB.java:134)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.Stmt.execute(Stmt.java:113)
at anywheresoftware.b4j.objects.SQL.ExecNonQuery(SQL.java:156)
at b4j.example.keyvaluestore._createtable(keyvaluestore.java:62)
at b4j.example.keyvaluestore._initialize(keyvaluestore.java:357)
at b4j.example.tm._initialize(tm.java:1342)
at b4j.example.project._initializetm(project.java:706)
at b4j.example.project._open(project.java:826)
at b4j.example.main._menubar1_action(main.java:487)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.BA$1.run(BA.java:215)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please don't make duplicate posts.

Lets start from the beginner.

I'm testing this code on a Mac using B4J-Bridge and it works:
B4X:
#AdditionalJar: sqlite-jdbc-3.7.2
#AdditionalJar: bcprov-jdk15on-150
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private kvs As KeyValueStore
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
    kvs.Initialize(File.DirApp, "db.db")
    kvs.Put("key", "value")
    Log(kvs.Get("key"))
End Sub

Does it work for you?
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
Thanks for your answer, however with your example I have not solved anything, let me explain, if I start my simulation program with "b4j-bridge.jar" it works but not everything, because when I do the updates of 400 records with a "Do While" and running the command "DBUtils.UpdateRecord (DbApertura.cSQL," RubricaSms "," start of contract ", mRate.Get (" Rata1 "), WhereClausola1)" gives me this error "java.sql.SQLException: [ SQLITE_BUSY] The database file is locked (database is locked) ... "instead when I prepare the package and launch the command run_commad from mac gives me this message" iMac-di-roberto: ~ roberto $ / Users / roberto / tempjars / temp /build/run.command; exit;
() [jrt: /b4j/Files/Dialog.css]
keyvaluestore._put (java line: -1)
java.sql.SQLException: [SQLITE_CANTOPEN] Unable to open the database file (unable to open database file) ", you made an example with a KeyValueStore which would be a db encryption but I have a simple db with sqlite. This is my opening to the db

db:
Sub PreparaDB
If File.Exists (File.DirApp, "DbRubTel.db") = False Then
File.Copy (File.DirAssets, "DbRubTel.db" File.DirApp, "DbRubTel.db")
End If
cSQL.InitializeSQLite (File.DirApp, "DbRubTel.db", True)
dbPath = File.Combine (File.DirApp, "DbRubTel.db")
kvs.Initialize (File.DirApp, "DbRubTel.db")
kvs.Put ("key", "value")
Log (kvs.Get ( "key"))

cSQL.ExecNonQuery ("PRAGMA journal_mode = wal") 'is used to open SQLITE_BUSY
End Sub
/QUOTE]
regards
 
Upvote 0
Top