B4A Library Jackcess library - uses MS Access database files

For access to later Access databases you can try this



The Jackcess library lets you read and update MS Access database files (mdb files). It supports Access versions 200 to 2010.

The library wraps the Jackcess Java library - details and licensing information are in the archive and the xml documentation.

Jackcess1.0.zip
 
Last edited:

MrKim

Well-Known Member
Licensed User
Longtime User
According to the jackcess FAQ on Sourceforge http://jackcess.sourceforge.net/faq.html#jdbc

"As of the 1.1.19 release, Jackcess has the ability to read the Queries saved in an Access database (i.e. interpret the data stored in the system Queries table). However, Jackcess does not have the ability to execute these Queries."

I am not exactly sure what this means. In the Access world tables and Queries are treated more or less the same when they are stored in the DB. EXECUTE refers to executable (MAKE TABLE, INSERT, etc.) queries. If Jackcess will open a query like it will a table, that would be a very big deal.
 

mbatgr

Active Member
Licensed User
Longtime User
Hi all,
This is my first post regarding B4A and MS Access using Jackcess library.
I played with the example and I did to read my database.
I tried to update a record, too but the problem is that while the new value is set when i re-run the project I found the old value.
Apparently there is something about Table updates.
I use this code

Cursor.SetCurrentRowValue("MyField",newvalue) ' i set the newvalue
msg = Cursor.GetColumnValue("MyField") & CRLF
Msgbox(msg, "MyField at" & ItemID) ' i get the newvalue

Cursor.UpdateCurrentRow(Array As Object(ItemID))
Table.UpdateCurrentRow(Array As Object(ItemID))

I did not get any error but the old value still exist when re-run the app and re-read the database!
I appreciate any Help...
 

elitevenkat

Active Member
Licensed User
Longtime User
Hi
I happen to see the code.
<code>
File.Copy(File.DirAssets, "Northwind.mdb", File.DirRootExternal, "Northwind.mdb")
</code>

I think you have to check for file existence before the copy command. I have not tested the example. When you re run, the mdb gets over written !!!
 

mbatgr

Active Member
Licensed User
Longtime User
thank you Elitevenkat. Yes the is true. Just now working with clear mind I discovered that in every start the db is dublicated. Now it works...thank you
for other users I need to mention that in regard to the code above they should remove the

Cursor.UpdateCurrentRow(Array As Object(ItemID))
and use just the

Table.UpdateCurrentRow(Array As Object(ItemID))

in order the table to be updated properly.
 

HavasuPreditor

Member
Licensed User
Longtime User
Hi All,
I'm new to B4a, but moving along nicely.
This library is working great, I'm able to open and read records without any problems.
but I am struggling with adding a row, in the docs it shows "(values() AsObject)" but I'm not sure what object it's looking for?
is there a chance someone might have an example of the "addrow" function, I'm sure I'm missing something simple.
also just for clarification, is any other version of the library available for B4A or is it still at version 1, the sourceforge site is showing 2.01 but I don't see an XML file to go with it, so if it is updateable, I'm not sure how to go about it.

thanks for the help, Carter
 

HavasuPreditor

Member
Licensed User
Longtime User
Hello Again,
I'm having another problem, hopefully there is an answer.
I'm working on an application that accesses quit a few .MDB files for varying locations, depending on user selections.
I'm using CIFS Manger to Mount a file location off the network to tablet, this works well. (/sdcard/CIFS/DB)
I'm using the Jackcess Library to access the .MDB files from that mount, again working well.

SerialLogDB.Open(NetworkPath & "/customer/" & CustomerSelected & "/" & "temp.accdb")

the above line opens the databases, and I can read from there without an issues.
but if I try and add a row:

SerialLogTable.Initialize(SerialLogDB.GetTable("Data Set"))
SerialLogTable.AddRow(ArrayAsObject("321568"))

I get the following error: java.nio.channels.NonWritableChannelException
based on the research I have done so far, this appears to be an issue with maybe permissions.
If I copy the file locally it seems to work.
I have the permissions for the location set to "allow full control" and have the CIFS Manger connecting with a domain account.
if that error a permissions issue or maybe there is something else I'm missing.

thanks for any help,
Carter
 

HavasuPreditor

Member
Licensed User
Longtime User
it's a tool that lets you mount a network location as a local sdcard.
there are few versions of it out there, Cifs Manger, Mount Manger and I'm sure there are others.
thanks, carter
 

boten

Active Member
Licensed User
Longtime User
probably a "protected" mdb but I got this error on the Access.Open(File.DirRootExternal & "/external_sd/abc/a3.mdb") stmt:

B4X:
Access.Open(File.DirRootExternal & "/external_sd/abc/a3.mdb")
java.io.IOException: jet format 'VERSION_3' does not support writing
Any way around this?
 

dibesw

Active Member
Licensed User
Longtime User
HI,
please anyone can help me.
All 3 Library+xml are copied into library folder
I have an error when I compile&run.
This is the screen...

jaccess.jpg


Thanks for any replay!!!
Amedeo
 

dibesw

Active Member
Licensed User
Longtime User
My code is...

jaccess4.jpg

I open mdb database in local disk (D)
My database is...
jaccess3.jpg


But why database is not found?
Where is the error?


** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_activity_resume (java line: 255)
java.io.FileNotFoundException: given file does not exist: D:/Utility/PocketPC/ANDROID/Jackcess/Jackcess/Files/northwind.mdb
at com.healthmarketscience.jackcess.Database.open(Database.java:647)
at com.healthmarketscience.jackcess.Database.open(Database.java:612)
at com.healthmarketscience.jackcess.Database.open(Database.java:582)
at com.healthmarketscience.jackcess.Database.open(Database.java:555)
at com.healthmarketscience.jackcess.Database.open(Database.java:531)
at com.healthmarketscience.jackcess.Database.open(Database.java:509)
at anywheresoftware.b4a.objects.JackcessDatabase.Open(JackcessDatabase.java:170)
at b4a.jackcessdemo.main._activity_resume(main.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
at b4a.jackcessdemo.main.afterFirstLayout(main.java:95)
at b4a.jackcessdemo.main.access$100(main.java:16)
at b4a.jackcessdemo.main$WaitForLayout.run(main.java:74)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
java.io.FileNotFoundException: given file does not exist: D:/Utility/PocketPC/ANDROID/Jackcess/Jackcess/Files/northwind.mdb
 

HavasuPreditor

Member
Licensed User
Longtime User
Hello All,
I'm having trouble with an Access97 DB.
My B4A program opens DB 2003 to 2010 just fine I can read and write.
I know 97 is read only, but I can't even get it to open.
when it try's with this line:
CustomerNamesDB.Open(NetworkPath & "/Customer Names.mdb")
I get this error:
java.io.IOException: jet format 'VERSION_3' does not support writing
I tried setting the DB file to read only, but then I get this error:
java.io.FileNotFoundException: NetworkPath: open failed: EACCES (Permission denied)

Do I need to open the 97 DB differently?
thanks, carter
 

Beja

Expert
Licensed User
Longtime User
Today I had the chance to try the example as is. what I got was a very long list of the MDB tables'
structures.. I write a few lines here by hand (after the headers).
Name: (MSysObjects)
ParentID
Type: 0x4 (LONG)
Number: 1
Length: 4
Variable Length: false
Name: (MSysObjects)
Type: 0xa (TEXT)
Number: 2
Length: 510

...and so on. See next page for screenshots
 
Last edited:
Top