I have a B4J project in which it creates a KVS store file.
On the first pass it writes the data to the file and its visible on read back. The file when viewed after the initial creation shows an SQLlite header - after the first write to the file that header is not visible anymore, or, has been overwritten. Which is likely the mistake I am making somewhere in writing to the .KVS file.
Been through a number of forum threads and not found any that have helped, or show a solution.
B4J is V9.10
KeyValueStore is V 2.30 (could be updated to 2.31)
Any assistance?
The relevant code part is below the log extract.
On the second pass I get the following in the log :
On the first pass it writes the data to the file and its visible on read back. The file when viewed after the initial creation shows an SQLlite header - after the first write to the file that header is not visible anymore, or, has been overwritten. Which is likely the mistake I am making somewhere in writing to the .KVS file.
Been through a number of forum threads and not found any that have helped, or show a solution.
B4J is V9.10
KeyValueStore is V 2.30 (could be updated to 2.31)
Any assistance?
The relevant code part is below the log extract.
On the second pass I get the following in the log :
clientID -> 206-0724
[IsInitialized=true, id=206-0724, project=test data 2
, DESCRIPTION=test data 2, timeWorked=0.0, startDate=25/07/2021
, endDate=31/07/2021, client=test data 2, address=test data 2
, phone==84-222-2222, rate=222.00, budget=2222.00
]
=========
25/07/2021
31/07/2021
=========
data file -> C:\Users\RabbitBush\AppData\Roaming\workTIME.kvs
write file -> C:\Users\RabbitBush\AppData\Roaming\workTIME.kvs
File \workTIME.kvs found
keyvaluestore._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv6 (java line: 62)
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.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.Stmt.execute(Stmt.java:113)
at anywheresoftware.b4j.objects.SQL.ExecNonQuery(SQL.java:161)
at b4j.example.keyvaluestore._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv6(keyvaluestore.java:62)
at b4j.example.keyvaluestore._initialize(keyvaluestore.java:355)
at b4j.example.projdescription._savebutton1_click(projdescription.java:328)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.BA$1.run(BA.java:233)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
CODE PART:
Private storageKVSData As KeyValueStore
If File.Exists(File.DirData(storageFldr), storageData) Then
Log("File " & storageData & " found")
storageKVSData.Initialize(File.DirData(storageFldr), storageData) ' for database files with keys
File.OpenOutput(File.DirData(storageFldr), storageData, True)
Log("File " & storageData & " opened ready to write")
File.WriteMap(File.DirData(storageFldr), storageData, mapProjects)
Log("File " & storageData & " data written")
mapProjects = File.ReadMap(File.DirData(storageFldr), storageData) 'test what it reads back
Log ("MAP contents - > " & mapProjects)
storageKVSData.Close
Log("File " & storageData & " CLOSED")
' read any data that are in the project file saved from before
' this will populate the table so that a project can be selected
Else
Log("There is no File: " & storageData)
''''msgLabel2.Text = "Work file workTIME created at " & DateUtils.TicksToString(DateTime.Now)
End If