The Easysoft ODBC-Access Driver is installed on the computer where your applications are running. ODBC applications access ODBC drivers through the ODBC Driver Manager and a data source. The data source tells the Driver Manager which ODBC driver to load and which Access database to connect to. This chapter describes how to create data sources, use DSN-less connections and configure the Easysoft ODBC-Access Driver.
Before setting up a data source, you must have successfully installed the Easysoft ODBC-Access Driver.
For Easysoft ODBC-Access Driver installation instructions, see Installation.
The Easysoft ODBC-Access Driver is a file-based ODBC driver that communicates directly with the Access database file. The database file must be accessible through the local file system on the machine where the Easysoft ODBC-Access Driver is installed.
If both Windows and Easysoft ODBC-Access Driver users will need to access the database file you can:
Alternatively, if only Easysoft ODBC-Access Driver users need to access the database file, you should:
Read this section to see which Easysoft ODBC-Access Driver deployment option is appropriate for you.
1. Where Does Your Database File Need To Be Located?
For performance reasons, you should locate the database file nearest to the applications that use it most intensively. If your Windows applications would be most adversely affected by opening a database file located on a remote machine, locate the database file on Windows. Otherwise, copy the database file to the Easysoft ODBC-Access Driver machine, and, if applicable, use Samba to expose the file to Windows users.
2. What Platform Do You Need To Access The Database File From?
Note For read-write access to the database file, you need to use a version of smbmount that can disable local file caching (directio option). There is a performance penalty associated with this option.
You also need to install the libsmbclient library, which the Easysoft ODBC-Access Driver uses to let Windows applications know when it has a database file open and to prevent other users from opening a database file it has opened for exclusive access. libsmbclient is part of the Samba suite.
This section describes how to configure the Easysoft ODBC-Access Driver to connect to an Access database by using a data source or a DSN-less connection string. The section assumes you are, or are able to consult with, a database administrator.
There are two ways to set up a data source to your Access data:
By default, the Easysoft ODBC-Access Driver installation creates a SYSTEM data source named [ACCESS_SAMPLE]. If you are using the unixODBC included in the Easysoft ODBC-Access Driver distribution, the SYSTEM odbc.ini file is in /etc.
If you built unixODBC yourself, or installed it from some other source, SYSTEM data sources are stored in the path specified with the configure option --sysconfdir=directory. If sysconfdir was not specified when unixODBC was configured and built, it defaults to /usr/local/etc.
If you accepted the default choices when installing the Easysoft ODBC-Access Driver, USER data sources must be created and edited in $HOME/.odbc.ini.
To display the directory where unixODBC stores SYSTEM and USER data sources, type odbcinst -j. By default, you must be logged in as root to edit a SYSTEM data source defined in /etc/odbc.ini. |
You can either edit the sample data source or create new data sources.
Each section of the odbc.ini file starts with a data source name in square brackets [ ] followed by a number of attribute=value pairs.
The Driver attribute identifies the ODBC driver in the odbcinst.ini file to use for a data source.
When the Easysoft ODBC-Access Driver is installed into unixODBC, an entry for the driver (Easysoft ODBC-ACCESS) is placed in odbcinst.ini.
For Easysoft ODBC-Access Driver data sources, you need to include a Driver = Easysoft ODBC-ACCESS entry.
To configure an Access data source, in your odbc.ini file, you need to specify:
mdbfile = /home/myuser/ms-access/Northwind.mdb
mdbfile = /home/myuser/ms-access/Northwind 2007.accdb
If you are using the Easysoft ODBC-Access Driver to open an database file that Windows users may also be accessing, specify these settings:
mdbfile = /mnt/accounts/access/Northwind.mdb
smbpath = smb://mswin_machine/accounts/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
mdbfile = /home/samba/sales/access/Northwind.mdb
smbpath = smb://samba_server/sales/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
smbuser = my_samba_share_valid_user
smbauth = my_samba_share_valid_password
The following attributes may be set in the odbc.ini file:
The Easysoft ODBC-Access Driver must be able to find the following shared objects, which are installed during the Easysoft ODBC-Access Driver installation:
By default, this is located in /usr/local/easysoft/unixODBC/lib.
By default, this is located in /usr/local/easysoft/lib.
By default, this is located in /usr/local/easysoft/lib.
By default, this is located in /usr/local/easysoft/lib.
You may need to set and export LD_LIBRARY_PATH, SHLIB_PATH or LIBPATH (depending on your operating system and run-time linker) to include the directories where libodbcinst.so, libeslicshr.so and libessupp.so are located.
The shared object file extension (.so) may vary depending on the operating system (.so, .a or .sl). |
The isql query tool lets you test your Easysoft ODBC-Access Driver data sources.
To test the Easysoft ODBC-Access Driver connection
1. Change directory into /usr/local/easysoft/unixODBC/bin.
2. Type ./isql -v data_source, where data_source is the name of the Easysoft ODBC-Access Driver data source.
If you are unable to connect, see Troubleshooting Database Connection Problems for help on solving some common connection problems.
3. At the prompt, type an SQL query. For example:
Type help to return a list of tables:
1. On the Easysoft ODBC-Access Driver machine, use smbmount to mount the Windows share where the database file is located.
# smbmount //mywindowsmachine/myshare /mylinuxmountpoint -o username=mywindowsuser,rw,directio
Important For read-write access to the database, you must specify the directio option when mounting the share. Check the man page for your version of smbmount to see whether it supports the directio option. Specifying directio turns off inode data caching on files opened on the mount. The Easysoft ODBC-Access Driver relies on this functionality when managing concurrent access to the database file.
When mounting the share, you need to supply the user name and password of a Windows user who has read, write, create and delete privileges for the share. When testing the Easysoft ODBC-Access Driver with a database file located in a Windows Vista share, this requirement equated to these Windows permissions:
These permissions allow the Easysoft ODBC-Access Driver to write to or create a locking information file (.ldb).
2. Configure the Easysoft ODBC-Access Driver data source.
# This Easysoft ODBC-Access Driver data source opens an Access
# database that is stored on a Windows share. The data source
# opens the database for shared read/write access; other users can
# open the database therefore.
# The Windows share (accounts) has been attached under /mnt on the
# Easysoft ODBC-Access Driver machine.
mdbfile = /mnt/accounts/access/Northwind.mdb
# The smb* attributes allow the Easysoft ODBC-Access Driver to
# manage concurrent access to the database.
# The SMB URL for the database on the Windows share.
smbpath = smb://mswin_machine/accounts/access/Northwind.mdb
# The path to the SMB client library on the
# Easysoft ODBC-Access Driver machine
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Windows user who has read and
# write privileges to the share.
# Opens the database for shared read/write access.
# This data source opens the same Access database for exclusive
# access; the Easysoft ODBC-Access Driver will prevent other
# users from accessing the database, therefore.
mdbfile = /mnt/accounts/access/Northwind.mdb
smbpath = smb://mswin_machine/accounts/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Windows user who can access the
# share and who has read and write privileges to the .mdb file.
# Opens the database for exclusive read/write access.
# This data source opens the same Access database for read-only
# access; the Easysoft ODBC-Access Driver will prevent its users
# from making updates to the database, therefore.
mdbfile = /mnt/accounts/access/Northwind.mdb
smbpath = smb://mswin_machine/accounts/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Windows user who has read
# Opens the database for read-only access.
For more information about Easysoft ODBC-Access Driver data source attributes, see Attribute Fields.
1. Copy the Access database file to a Samba share on the Easysoft ODBC-Access Driver machine.
The Easysoft ODBC-Access Driver requires the following Samba configuration options to be set for the share in which the database file is located.
2. Configure the Easysoft ODBC-Access Driver data source.
# This Easysoft ODBC-Access Driver data source opens an Access
# database that is stored on a Samba share. The data source
# opens the database for shared read/write access; other users can
# open the database therefore.
mdbfile = /home/samba/sales/access/Northwind.mdb
# The smb* attributes allow the Easysoft ODBC-Access Driver to
# manage concurrent access to the database.
# The SMB URL for the database on the Samba share.
smbpath = smb://samba_server/sales/access/Northwind.mdb
# The path to the SMB client library on the
# Easysoft ODBC-Access Driver machine
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Samba user who has read/write
smbuser = my_samba_share_valid_user
smbauth = my_samba_share_valid_password
# Opens the database for shared read/write access.
# This data source opens the same Access database for exclusive
# access; the Easysoft ODBC-Access Driver will prevent other
# users from accessing the database, therefore.
mdbfile = /home/samba/sales/access/Northwind.mdb
smbpath = smb://samba_server/sales/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Samba user who has read/write
smbuser = my_samba_share_valid_user
smbauth = my_samba_share_valid_password
# Opens the database for exclusive read/write access.
# This data source opens the same Access database for read-only
# access; the Easysoft ODBC-Access Driver will prevent its users
# from making updates to the database, therefore.
mdbfile = /home/samba/sales/access/Northwind.mdb
smbpath = smb://samba_server/sales/access/Northwind.mdb
smblib = /usr/lib/libsmbclient.so
# The user name and password of a Samba user who has read
smbuser = my_samba_share_valid_user
smbauth = my_samba_share_valid_password
# Opens the database for read-only access.
This section lists some common connection problems and their solutions.
The Easysoft ODBC-Access Driver can open either a local or remote Access database file (.mdb or .accdb). The path to the database file is specified in the Easysoft ODBC-Access Driver data source in /etc/odbc.ini.
In the Easysoft ODBC-Access Driver data source, check the mdbfile attribute value.
Use ls to check that the mdbfile attribute in your data source specifies a valid path and that the directory is accessible.
If the ls command output contains "permission denied", contact your administrator. The directory containing the database file needs to be accessible (execute permission set) to you.
If the path is not valid, check with your administrator whether the database file is located on another machine. (The Easysoft ODBC-Access Driver can open a database file that is located on a Windows share.) If the database file is remote, use the mount command to check whether the share has been attached on the Easysoft ODBC-Access Driver machine. There should be an entry in the mount command output that corresponds with the directory specified with mdbfile. For example:
/dev/sda3 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
//mywindowsmachine/myshare on /mnt/myshare type smbfs (rw)
mdbfile = /mnt/myshare/Northwind.mdb
If the mount command does not show the mount point specified in the mdbfile attribute, consult with your administrator. The share on which the database file is located needs to be mounted.
If the database file is on a Windows share, the user specified when mounting the share needs to have read, write, create and delete permissions for the share. When testing the Easysoft ODBC-Access Driver with a database file located in a Windows Vista share, this requirement equated to these Windows permissions:
If the database file is located on Unix, the Easysoft ODBC-Access Driver will also return a "Failed to open MDB file" if:
1. The user running the application that is connecting to the data source only has read access to a local database file.
The user specified by smbuser only has read access to a database file located on a Samba share.
2. The readonly attribute in the data source is set to yes. (Change this attribute's value to no and try again.)
The Easysoft ODBC-Access Driver uses the libsmbclient library, which is part of the Samba suite, to:
Without this mechanism, there is the potential for database file corruption when Windows users and Easysoft ODBC-Access Driver users are working with the database specified by mdbfile.
To configure the driver for use with libsmbclient you use the smb* attributes in the driver data source.
If the "Failed to open SMB channel" error contains "file not found", check the smbpath attribute in the data source. The smbpath attribute needs to specify the SMB URL for the database file specified with mdbfile. The SMB URL has the format smb://host/share/path/filename.
In the following example, a remote Access database named Northwind.mdb is located on the Easysoft ODBC-Access Driver machine in /mnt/myshare_mountdir. The mount command shows that /mnt/myshare_mountdir is the mount point for a share named myshare on a machine named myremotemachine.
mdbfile = /mnt/myshare_mountdir/Northwind.mdb
//myremotemachine/myshare on /mnt/myshare_mountdir type smbfs (rw)
The SMB URL for the database file would therefore be:
smb://myremotemachine/myshare/Northwind.mdb
If the "Failed to open SMB channel" error contains "errno=13", check the smbuser and smbauth attributes in the data source.
If the database file is located on a Samba share, the smbuser and smbauth attributes need to specify the user name and password for a Samba user (created with Samba tools such as smbpasswd) who has read access to the share. To open a database file for read-write access (readonly data source attribute set to no), the Samba user also needs write access to the share).
If the database file is located in a Windows share, the smbuser and smbauth attributes need to specify the user name and password for a Windows user who can access the share. If smbuser only has read privilege to the database file (as opposed to read and write), the readonly attribute in the data source needs to be set to yes. Otherwise, an "errno=13" error will be returned.
To allow its users to safely edit a database file that Windows users may also be accessing and updating, the Easysoft ODBC-Access Driver uses a locking information file (.ldb).
The driver uses a .ldb file to:
The Easysoft ODBC-Access Driver may have to create and delete a .ldb file as well as write to it. If directory permissions prevent the Easysoft ODBC-Access Driver from writing to/creating a .ldb file, the driver may return a "Could not open/create lock file, check sharing permissions" error.
If you get this error when opening a database file that Windows users do not require access to, specify an alternative .ldb file directory with the lockfile data source attribute. Specify a directory where you and other users who connect to the data source have write access to. For example:
This table lists the various permissions that may need to be set to allow the Easysoft ODBC-Access Driver to open your Access database file (.mdb or .accdb).
In addition to using a data source, you can also connect to a database by using a DSN-less connection string of the form:
SQLDriverConnect(..."DRIVER={Easysoft ODBC-ACCESS};
where path is the path to the database file on the Easysoft ODBC-Access Driver machine.
Other Easysoft ODBC-Access Driver attribute settings, as described in Setting Up Data Sources, can be added to the connection string using the same PARAMETER=value; format. For example:
"DRIVER={Easysoft ODBC-ACCESS};MDBFILE=/home/myuser/ms_access/Northwind.mdb;"