B4J Code Snippet [DBF] Reading Visual Foxpro DBF using JDBC

This snippet demonstrates how to use FoxPro JDBC Driver to read DBF file. The driver read the DBF file and generate a H2 cache in C:/Users/<UserName>/.DbSchema/jdbc-dbf-cache/
Compare to jDBF driver, this driver can read more field types such as timestamp (T) or datetime, General, Memo and more.

Download FoxPro JDBC Driver: https://dbschema.com/jdbc-drivers/FoxProJdbcDriver.zip
More info: https://dbschema.com/jdbc-driver/FoxPro.html
GitHub: https://github.com/wise-coders/dbf-jdbc-driver

[DBF] Read/Write DBF file using jDBF: https://www.b4x.com/android/forum/threads/dbf-read-write-dbf-file-using-jdbf.136728/

H2 Database: https://www.b4x.com/android/forum/threads/h2-database.132688/

B4X:
#Region Project Attributes
    #MainFormWidth: 900
    #MainFormHeight: 500
#End Region
#AdditionalJar: javadbf-1.13.2
#AdditionalJar: dbschema-dbf-jdbc1.0.jar
#AdditionalJar: h2-1.4.200.jar
' Download FoxPro JDBC Driver: https://dbschema.com/jdbc-drivers/FoxProJdbcDriver.zip
' More info: https://dbschema.com/jdbc-driver/FoxPro.html

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
   
    Public dbf As JdbcSQL
    Private driver As String = "com.dbschema.xbase.DbfJdbcDriver"
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//Aeric//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
    Private B4XTable1 As B4XTable
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
   
    Wait For (ReadTable) Complete (Success As Boolean)
    If Success Then
        xui.MsgboxAsync("Success", "ReadTable")
    End If
End Sub

Sub Connect As Boolean
    dbf.Initialize(driver, jdbcUrl)
    If dbf.IsInitialized Then
        Return True
    End If
    Return False
End Sub

Sub ReadTable As ResumableSub
    Dim Success As Boolean
    If Connect Then
        Try
            Dim sf As Object = dbf.ExecQueryAsync("dbf", "SELECT * FROM sample", Null)
            Wait For (sf) dbf_QueryComplete (Success As Boolean, res As JdbcResultSet)
            If Success Then              
                Log(" ")
                Do While res.NextRow
                    Log($"id: ${res.GetInt("id")} | Name: ${res.GetString("item_name")} | Barcode: ${res.GetInt("barcode")} | Cost: ${res.GetDouble("avg_cost")} | Created: ${res.GetString("created_on")}"$)
                Loop
                res.Close
            End If
           
            Log(" ")
           
            ' B4J Tutorial H2 Database
            ' https://www.b4x.com/android/forum/threads/h2-database.132688/
            Dim driver As String = "org.h2.Driver"
            Dim url As String = $"jdbc:h2:C://Users//Aeric//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$
            Dim DB As SQL
            DB.Initialize(driver, url)
           
            ' Test UPDATE
            DB.ExecNonQuery2("UPDATE sample SET ITEM_NAME = ? WHERE ID = ?", Array("Testing", 1))
           
            B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_NUMBERS)
            B4XTable1.AddColumn("Name", B4XTable1.COLUMN_TYPE_TEXT)
            B4XTable1.AddColumn("Barcode", B4XTable1.COLUMN_TYPE_TEXT)
            B4XTable1.AddColumn("Cost", B4XTable1.COLUMN_TYPE_NUMBERS)
            B4XTable1.AddColumn("Created", B4XTable1.COLUMN_TYPE_TEXT)
           
            Dim data As List
            data.Initialize
           
            Dim res As ResultSet = DB.ExecQuery("SELECT * FROM sample")
            Do While res.NextRow
                Log($"id: ${res.GetInt("id")} | Name: ${res.GetString("item_name")} | Barcode: ${res.GetInt("barcode")} | Cost: ${res.GetDouble("avg_cost")} | Created: ${res.GetString("created_on")}"$)
                data.Add(Array(res.GetInt("id"), res.GetString("item_name"), res.GetInt("barcode"), res.GetDouble("avg_cost"), res.GetString("created_on")))
            Loop
            res.Close
            B4XTable1.SetData(data)
            B4XTable1.Refresh
            Success = True
        Catch
            Log(LastException)
        End Try
        CloseConnection
    End If
    Return Success
End Sub

Sub CloseConnection
    dbf.Close
End Sub
 

Attachments

  • jdbcDBF.zip
    22.3 KB · Views: 262

AnandGupta

Expert
Licensed User
Longtime User
Hi @aeric

I got below error, seems like java version old.
B4X:
main._vv6 (java line: 135)
java.lang.UnsupportedClassVersionError: com/dbschema/xbase/DbfJdbcDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:52)
    at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
    at b4j.example.main._vv6(main.java:135)
    at b4j.example.main$ResumableSub_ReadTable.resume(main.java:258)
    at b4j.example.main._vv7(main.java:222)
    at b4j.example.main$ResumableSub_AppStart.resume(main.java:87)
    at b4j.example.main._appstart(main.java:56)
    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:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)

I want to stay with jaba 8 only as I have clients with it.
What I need to update to fix this error.
I am checking your code as it is.
 

aeric

Expert
Licensed User
Longtime User
Hi @aeric

I got below error, seems like java version old.
B4X:
main._vv6 (java line: 135)
java.lang.UnsupportedClassVersionError: com/dbschema/xbase/DbfJdbcDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:52)
    at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
    at b4j.example.main._vv6(main.java:135)
    at b4j.example.main$ResumableSub_ReadTable.resume(main.java:258)
    at b4j.example.main._vv7(main.java:222)
    at b4j.example.main$ResumableSub_AppStart.resume(main.java:87)
    at b4j.example.main._appstart(main.java:56)
    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:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)

I want to stay with jaba 8 only as I have clients with it.
What I need to update to fix this error.
I am checking your code as it is.
In this case, we need to test whether we can compile the source using Java 8.
 

aeric

Expert
Licensed User
Longtime User
I am feeling lucky.
I open the GitHub project in IntelliJ IDEA: https://github.com/wise-coders/dbf-jdbc-driver
Fixed some Gradle deprecated keywords: https://stackoverflow.com/questions/23796404/could-not-find-method-compile-for-arguments-gradle
Compile into JAR (with Java 1.8): https://www.jetbrains.com/help/idea/getting-started-with-gradle.html#deploy_gradle
Then change the following line in B4J project:
B4X:
Private driver As String = "com.dbschema.dbf.JdbcDriver" ' "com.dbschema.xbase.DbfJdbcDriver"

Voila!

Attached is the dbschema-dbf-jdbc1.0.jar I have recompile.
 

Attachments

  • dbschema-dbf-jdbc1.0.jar
    25 KB · Views: 216

AnandGupta

Expert
Licensed User
Longtime User
Got below error,
B4X:
main._vv6 (java line: 135)
java.lang.RuntimeException: Class not found: com.dbschema.dbf.DbfJdbcDriver
Are you missing an #AdditionalJar attribute setting?
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:54)
    at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
    at b4j.example.main._vv6(main.java:135)
    at b4j.example.main$ResumableSub_ReadTable.resume(main.java:258)
    at b4j.example.main._vv7(main.java:222)
    at b4j.example.main$ResumableSub_AppStart.resume(main.java:87)
    at b4j.example.main._appstart(main.java:56)
    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:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

I made below changes,
B4X:
#Region Project Attributes
    #MainFormWidth: 900
    #MainFormHeight: 500
#End Region
#AdditionalJar: javadbf-1.13.2
#AdditionalJar: dbschema-dbf-jdbc1.0.jar
#AdditionalJar: h2-1.4.200.jar
' Download FoxPro JDBC Driver: https://dbschema.com/jdbc-drivers/FoxProJdbcDriver.zip
' More info: https://dbschema.com/jdbc-driver/FoxPro.html

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
   
    Public dbf As JdbcSQL
'    Private driver As String = "com.dbschema.xbase.DbfJdbcDriver" ' <----- original
    Private driver As String = "com.dbschema.dbf.DbfJdbcDriver"  '<------- changed
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//Aeric//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
    Private B4XTable1 As B4XTable
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
   
    Wait For (ReadTable) Complete (Success As Boolean)
    If Success Then
        xui.MsgboxAsync("Success", "ReadTable")

Maybe something more need to be done.
 

Attachments

  • ba1.png
    ba1.png
    7.7 KB · Views: 177

AnandGupta

Expert
Licensed User
Longtime User
Did you copy the new jar file to additional folder?
Obviously.
Again I downloaded the jar to make it sure and copied it to additional folder, overwriting the existing one as original and this jar has same name.
Below is my additional folder,

ba1.png

I extracted the original project source and compiled it. Below is the code,

ba2.png

Again got error,

B4X:
main._vv6 (java line: 135)
java.lang.RuntimeException: Class not found: com.dbschema.xbase.DbfJdbcDriver
Are you missing an #AdditionalJar attribute setting?
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:54)
    at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
    at b4j.example.main._vv6(main.java:135)
    at b4j.example.main$ResumableSub_ReadTable.resume(main.java:258)
    at b4j.example.main._vv7(main.java:222)
    at b4j.example.main$ResumableSub_AppStart.resume(main.java:87)
    at b4j.example.main._appstart(main.java:56)
    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:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)

Note com.dbschema.xbase.DbfJdbcDriver, has xbase in it and I changed to dbf thinking it may be the problem but error still.

May be the uploaded jar is different.
 

aeric

Expert
Licensed User
Longtime User
com.dbschema.xbase.DbfJdbcDriver
This is the original jar in post #1 that only support Java 11. The project in post #1 is compatible with this version.

The jar I attached in post #5 is recompiled by me using Java 8. You need to modify the code as explained in post #5. Yes, they are using the same name.
 

AnandGupta

Expert
Licensed User
Longtime User
Yes my fault. I did not copied the code but manually changed xbase to dbf, which was wrong.

But now I get error in line 35 as below, in debug mode. In release mode the windows opens and closes.
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 35 (Main)

The source line 35 is as below,
ba3.png

the data sample is here
ba4.png
 

aeric

Expert
Licensed User
Longtime User
B4X:
    Public dbf As JdbcSQL
    Private driver As String = "com.dbschema.dbf.JdbcDriver" ' "com.dbschema.xbase.DbfJdbcDriver"
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//[B]Aeric[/B]//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
Yes, sometimes you need to pay attention to the minor and detail change.
Do you change the path to your username?
 

AnandGupta

Expert
Licensed User
Longtime User
B4X:
    Public dbf As JdbcSQL
    Private driver As String = "com.dbschema.dbf.JdbcDriver" ' "com.dbschema.xbase.DbfJdbcDriver"
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//[B]Aeric[/B]//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
Yes, sometimes you need to pay attention to the minor and detail change.
Do you change the path to your username?
The path was the problem. I did not noticed it as in DBF_Read sample the book2 was in object and so I thought is was Ok here too.

It works now as below, logs show the data read, the b4xtable is blank as codes are commented.

ba5.png

So success at last.

Thanks for your patience and guidance šŸ™
 

AnandGupta

Expert
Licensed User
Longtime User
One more point,

Below changes works, as the sample dbf is not in user folder but separate drive
B4X:
'    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//Aeric//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/e://Appl//Android//@Samples//Advanced//jdbcDBF//jdbcDBF//Objects//data?[charset=GBK]"

But below I could not figure out how to change,
B4X:
'            Dim url As String = $"jdbc:h2:C://Users//Aeric//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$
            Dim url As String = $"jdbc:h2:C://Users//Anand//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$

The above change does not work.
 

aeric

Expert
Licensed User
Longtime User
One more point,

Below changes works, as the sample dbf is not in user folder but separate drive
B4X:
'    Private jdbcUrl As String = "jdbc:dbschema:dbf:/C://Users//Aeric//Desktop//jdbcDBF//Objects//data?[charset=GBK]"
    Private jdbcUrl As String = "jdbc:dbschema:dbf:/e://Appl//Android//@Samples//Advanced//jdbcDBF//jdbcDBF//Objects//data?[charset=GBK]"

But below I could not figure out how to change,
B4X:
'            Dim url As String = $"jdbc:h2:C://Users//Aeric//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$
            Dim url As String = $"jdbc:h2:C://Users//Anand//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$

The above change does not work.
You need to locate the jdbc-dbf-cache folder in your user folder. As you can see the .DbSchema had a leading period so the folder maybe hidden. You need to locate the folder and look for the cache file which has a random string name and most probably is different with mine every time the file is being read.
 

AnandGupta

Expert
Licensed User
Longtime User
I remember this (here from Wikipedia):
The .dbf file extension represents the dBase database file. The file type was introduced in 1983 with dBASE II.
:)

80s :(
Yes true and we have over 5000 clients using our financial and inventory application which uses dbf files, http://www.coral.in/
So to satisfy those clients who are happy with a simple application environment than mighty sql environment, we have to cater for them.
We do have sql application but have lesser number for clients on it.
Oh, yeah there are a still a few using WinXp !
 

AnandGupta

Expert
Licensed User
Longtime User
You need to locate the jdbc-dbf-cache folder in your user folder. As you can see the .DbSchema had a leading period so the folder maybe hidden. You need to locate the folder and look for the cache file which has a random string name and most probably is different with mine every time the file is being read.
Found it. There are three as below,

ba6.png

I used the first one but error,

B4X:
'            Dim url As String = $"jdbc:h2:C://Users//Aeric//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$
            Dim url As String = $"jdbc:h2:c://Users//Anand//.DbSchema//jdbc-dbf-cache\bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$

B4X:
Dec 19, 2021 5:36:05 PM com.dbschema.dbf.JdbcDriver getConnection
INFO: Create H2 database 'jdbc:h2:file:file:/C:/Users/Anand/.DbSchema/jdbc-dbf-cache/daa2282c5a42b9e063c02a54a9aa35b7;database_to_upper=false'
Dec 19, 2021 5:36:05 PM com.dbschema.dbf.io.DBFtoH2 isFileTransferred
INFO: File e:\Appl\Android\@Samples\Advanced\jdbcDBF\jdbcDBF\Objects\data\sample.dbf is already loaded in H2.
 
id: 0 | Name: Aaa aaaa | Barcode: 1001 | Cost: 1.2346 | Created: 2021-12-14 10:31:59.999
id: 1 | Name: Bbb bbbb | Barcode: 1002 | Cost: 4.9752 | Created: null
id: 2 | Name: Ccc cccc | Barcode: 1003 | Cost: 0.0 | Created: 2020-12-14 00:00:00
 
(JdbcSQLSyntaxErrorException) org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "sample" not found; SQL statement:
UPDATE sample SET ITEM_NAME = ? WHERE ID = ? [42102-200]

sample table missing !
 

aeric

Expert
Licensed User
Longtime User
Found it. There are three as below,

View attachment 123199

I used the first one but error,

B4X:
'            Dim url As String = $"jdbc:h2:C://Users//Aeric//.DbSchema//jdbc-dbf-cache/bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$
            Dim url As String = $"jdbc:h2:c://Users//Anand//.DbSchema//jdbc-dbf-cache\bc2c5c3e2a2f9142b893f50d4287f8c1;database_to_upper=false"$

B4X:
Dec 19, 2021 5:36:05 PM com.dbschema.dbf.JdbcDriver getConnection
INFO: Create H2 database 'jdbc:h2:file:file:/C:/Users/Anand/.DbSchema/jdbc-dbf-cache/daa2282c5a42b9e063c02a54a9aa35b7;database_to_upper=false'
Dec 19, 2021 5:36:05 PM com.dbschema.dbf.io.DBFtoH2 isFileTransferred
INFO: File e:\Appl\Android\@Samples\Advanced\jdbcDBF\jdbcDBF\Objects\data\sample.dbf is already loaded in H2.
 
id: 0 | Name: Aaa aaaa | Barcode: 1001 | Cost: 1.2346 | Created: 2021-12-14 10:31:59.999
id: 1 | Name: Bbb bbbb | Barcode: 1002 | Cost: 4.9752 | Created: null
id: 2 | Name: Ccc cccc | Barcode: 1003 | Cost: 0.0 | Created: 2020-12-14 00:00:00
 
(JdbcSQLSyntaxErrorException) org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "sample" not found; SQL statement:
UPDATE sample SET ITEM_NAME = ? WHERE ID = ? [42102-200]

sample table missing !
If you only work with 1 database then I would suggest delete all the cache files to avoid confusion. Let the library generate a new cache file and use the new file name.
 

aeric

Expert
Licensed User
Longtime User
Yes true and we have over 5000 clients using our financial and inventory application
Wow!
The reason I work with the DBF file is recently there is a potential client looking to integrate with the UBS. It is an old accounting software in Malaysia and there are many companies still using it.
 
Top