Android Question B4A + ucanaccess = Problem

vmag

Active Member
Hello everyone
It's been a long time, I wonder if anyone managed to work fully in B4A with ucanaccess ?
There are no problems with this in B4J:
1. plug-ins
B4X:
#AdditionalJar: ucanaccess-5.0.0.jar
#AdditionalJar: hsqldb-2.5.0.jar
#AdditionalJar: jackcess-3.0.1.jar
#AdditionalJar: commons-logging-1.2.jar
#AdditionalJar: commons-lang3-3.8.1.jar
2. Connecting to the database:
B4X:
Dim ConDBA As SQL
ConDba.Initialize("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess:// "&DBFile &"; memory=" & False&"; showSchema=" & True&"; openExclusive=" & False & "; preventReloading= " & True)
and we work ...

But in B4A I can't do it...
First, it is not clear how to connect these five modules, perhaps other operators (not #AdditionalJar)?
Secondly, it is not clear how to declare the ConDBA variable, because in this case, for B4A, the connection does not correspond to ucanaccess, but directly to SqLite.

Can anyone have a complete code example of at least connecting to the Ms access database via ucanaccess from B4A ?
 

vmag

Active Member
Thanks,
1. If we connect it like this:
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
    #AdditionalJar: ucanaccess-5.0.0.jar
    #AdditionalJar: hsqldb-2.5.0.jar
    #AdditionalJar: jackcess-3.0.1.jar
    #AdditionalJar: commons-logging-1.2.jar
    #AdditionalJar: commons-lang3-3.8.1.jar
#End Region
Then we get compilation errors:
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2 errors; aborting

The result is the same on jdk11, jdk14, and JDK Oracle 1.8.0_261
2. How do I connect the Jdbc SQL library instead of SQL ? It is not in the list of libraries...
 
Upvote 0

vmag

Active Member
It is a pity, ucanaccess is very powerful, universal and at the same time standard from the point of view of the sql language...
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
It is a pity, ucanaccess is very powerful, universal and at the same time standard from the point of view of the sql language...
And is targeting desktop Java environments, not Android. You’ll have to create a ticket with the writers of ucanaccess and see if they can adapt their libraries to work with Android. That adaption might be impossible if ucanaccess relies on features greater than Java 1.7 that cannot be addressed/backported via jettification.
 
Upvote 0

vmag

Active Member
And is targeting desktop Java environments, not Android.
To his great surprise - for me personally, the desktop differs from the top only by the fact that the desktop is on the table, and one of the top palm...
I spent my adult life doing databases, specifically retail trade and services, and in this
the sense of having a powerful tool for work with databases - any Android instrument would have enormous advantages...
In Russia one of the most common products is accounting 1C, but because she was indifferent to the camera, gps, dialer, etc.,
the secret is simple - surrounded by records and accounts, and is primarily a repository of information...
The one who first drags the database management tools to the phone will conquer the whole world...
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The one who first drags the database management tools to the phone will conquer the whole world...
1) The iPhone has even less support for direct database access.
2) Nothing keeps you from accessing a database indirectly. If you think about it, a user should never have direct access to a DB. As to indirect access, in the B4X world, take a look at jRDC2
3) As to tools for administrators? In the windows world, RDP over VPN works like a charm to give one access to native database management tools. For other platforms, there are various solutions out there (Parallels, AnyDesk, TeamViewer, SSH, etc), many of which can also be used for windows (if one does not want to use RDP)
 
Upvote 0

vmag

Active Member
1) The iPhone has even less support for direct database access.
...
Yeah, I don't have...
The fact that I'm trying to create a simple single-user Android app for yourself
for example, financial accounting, and now is acceptable to me storage (for certain reasons) it's ms access...

In b4j I managed to do this without any problems through the use of ucanaccess,
but I was very disappointed when I discovered that ucanaccess does not work with b4a...

On the other hand, I'm more than a week on this forum can't find a single full example
by working with ms access using the Jackcess library in b4a, I at least understand how to perform
basic operations:
- read the table
- add an entry to the table
- delete record
- edit record

on forum many write, that precisely with this they have no problems, but no one puts
their examples, I suspect that there is not much to spread... most likely it is not very convenient...
If data filtering can still be done by yourself when reading the table, then in the case of
if Jackcess can't read queries as tables, then displaying information on the screen without
sorting doesn't make much sense...

If someone has an example of working with a table in the mdb (ms access) file using Jackcess,
please share it so that I either calm down or continue working...
 
Upvote 0

vmag

Active Member
Thank you very much for the link!
I will definitely look at it and test it next week,
I had to change my priorities for other work because of this problem...
I really hope that this will help me...
 
Upvote 0

vmag

Active Member
Dear OliverA, You are indeed an expert! The idea to wrap ucanaccess 4 in The JDBC SQL library for B4A turned out to be original and workable. After some minor improvements to Your example, I succeeded. Thank You! I wish you further creative success!
 
Upvote 0
Top