Android Question How to connect Database FoxPro With JdbcSQL and jRDC2

jeb med

Member
Hello everyone;

I need help I want connect to FoxPro database.

using method : JdbcSQL Directly Connect And using jRDC2

Thank You and Best Regards
 

PaulMeuris

Active Member
Licensed User
How old is the FoxPro database?
Is it a Visual FoxPro database (Microsoft)?
Can you migrate the data to an Access database?
 
Upvote 0

jeb med

Member
How old is the FoxPro database?
Is it a Visual FoxPro database (Microsoft)?
Can you migrate the data to an Access database?
First release 1984 January 2015 the latest update version "Visual FoxPro 9.0"
Yes is Microsoft
Yes, I can migrate data to an Access database, but the client already has a program linked to this database
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
This one can read dbf files, but is in B4J
 
Upvote 0

jeb med

Member
This one can read dbf files, but is in B4J
I tried this code but it doesn't work

Public Sub SQLConnect

Private driver As String = "com.dbschema.dbf.JdbcDriver"
Private jdbcUrl As String = "jdbc:dbschema:dbf:\\192.168.225.254:1433\\atls\\MP2022"
sql1.Initialize(driver, jdbcUrl)

End Sub
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Private driver As String = "com.dbschema.dbf.JdbcDriver"
According to the site it's
  • Java Driver Class: com.dbschema.xbase.DbfJdbcDriver
It may not be free though...
 
Upvote 0

jeb med

Member
I suggest you try to make it work with jRDC2 first.
Create a small example with sample database file and try access using a B4J client. Once succeed, try with B4A.

I think this post is more helpful.
https://www.b4x.com/android/forum/threads/dbf-reading-visual-foxpro-dbf-using-jdbc.136840/
Now I tried to connect using jRDC2 in B4j
And it's been done
I will apply the same in B4a
jdbcDBF.jpg
 
Upvote 0

jeb med

Member
I tried to connect to the database on my computer
But I think the way i wrote it is incorrect :

Sub Class_Globals
Private Root As B4XView
Private xui As XUI

Public dbf As JdbcSQL
Private driver As String = "com.dbschema.dbf.JdbcDriver"
Private jdbcUrl As String = "jdbc:dbschema:dbf://192.168.225.42/C:/data/?[charset=GBK]"

Private B4XTable1 As B4XTable
End Sub
B4a jbdcDBF.jpg

I suggest you try to make it work with jRDC2 first.
Create a small example with sample database file and try access using a B4J client. Once succeed, try with B4A.

I think this post is more helpful.
https://www.b4x.com/android/forum/threads/dbf-reading-visual-foxpro-dbf-using-jdbc.136840/
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The JDBC driver is for local access only. If you want to use the driver to allow remote devices to access your DBF files, you'll have to use the driver with jRDC2.
 
Upvote 0

jeb med

Member
The JDBC driver is for local access only. If you want to use the driver to allow remote devices to access your DBF files, you'll have to use the driver with jRDC2.
But I've already remotely connected via JDBC
with the database ms sql server
And it works


Public Sub SQLConnect

ConnStr = "//192.168.225.4:1433"
DBName = "hi4200"
UserName = "sa"
PasswordTb = "us@2023"

sql1.InitializeAsync("sql2", "net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver:" & ConnStr & ";databaseName=" & DBName & ";user=" & UserName & ";password=" & PasswordTb & ";appname=SKMJL;wsid=TEST;loginTimeout=10;socketTimeout=10", "", "")
sql1.Close

End Sub
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
[DBF] Read/Write DBF file using jDBF

[DBF] Reading Visual Foxpro DBF using JDBC

Since you never asked me about the difference between the both Code Snippets above, I assume you have read the details.
However, please let me point out again some important points.

1. Both solutions are B4J projects
2. It is not meant to work straight away in B4A
3. They are depends on third party Java libraries which access through JavaObject
4. The first snippet is simple as it only depends on one library. The drawback is it doesn't support some column types such as datetime field.
5. The second snippet is more complicated as the jdbc driver provided by dbschema requires H2 library. It depends on 3 third party libraries. What the driver actually do is, it created a clone of the original dbf file into a cache. Any SQL query or command operations doesn't have effect to the original dbf file. To write back the changes, you may also need to use JavaObject to execute a command as stated in the Github readme. (I think many wouldn't have read it)
Java:
Statement st = connection.createStatement();
st.execute("save dbf to <folder_path>");

At that time I shared the snippets, I was creating a POC for a potential customer. So I only focus on reading the data out of the DBF file. Very unfortunate, I didn't get the project.
 
Upvote 0
Top