[Gambas-user] Accessing a microsoft database from gambas

Caveat Gambas at ...1950...
Wed Aug 3 19:50:08 CEST 2011


[resending as the jar file was too big... oops]

For now, I've made the jackcess library callable from Gambas via a
simple client-server mechanism.

Attached to this email is a jar file which creates a server that uses
the jaccess library to get to your Access Database and provides a
simple command interface over a socket to Gambas (or any other language
that supports sockets, in fact).  You'll also need commons-lang-2.6.jar,
commons-logging-1.1.1.jar and jackcess-1.2.4.jar... save them in a dir
called AccessReader_lib.  Extract the jar file attached to this mail
into the same dir as the one in which you created the AccessReader_lib
dir (so in the one dir you'll have the file AccessReader.jar and the dir
AccessReader_lib).

Now run:

java -jar AccessReader.jar --port 4444

This will create a server listening on port 4444.  To test that the
server is up and running and able to connect to your Access Databases,
try the following commands (obviously replacing things like your_user,
your_access_db etc.) in a terminal:

telnet localhost 4444
open /home/your_user/Documents/your_access_db.mdb
tables
cols one_of_your_tables
cursor one_of_your_tables
next
next 5
quit

The tar file attached to this mail is a sample Gambas3 client for the
java AccessReader.  Run the program, click on the big Connect button
(localhost and 4444 should be OK for the host and port but obviously can
be changed if you decide to run the AccessReader server on another
machine for e.g.).  Once you have connected, enter the path to one of
your Access Databases and hit the Open button.  The drop-down should get
populated with the tables in your Access Database.  Selecting a table
from the drop-down will dump that table to the grid view underneath.  

The paging spin-box controls how many records we get at once from the
AccessReader server.
If you are dumping a big table and get bored, just double-click the
gridview to cancel the current operation.

[Richard, this is an update to what I sent you last night with the major
change being the paging (and re-packaging the jar because it was too
big), it's now several orders of magnitude faster!!]

Hope somebody finds this useful...

Regards,
Caveat

On Tue, 2011-08-02 at 13:09 +0200, Benoît Minisini wrote:
> > LOL, I spent several days banging my head against a wall trying to get
> > this to work (I think you have to go through ODBC) and eventually gave
> > up and turned to java.  There's a nice java library called jackcess for
> > this.
> > 
> 
> Maybe that library could be translated in Gambas...
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: AccessReader.jar
Type: application/x-java-archive
Size: 21857 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20110803/1ad9dcd6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DatabaseClient.tar
Type: application/x-tar
Size: 40960 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20110803/1ad9dcd6/attachment.tar>


More information about the User mailing list