Installation, configuration, guides and tips

Here you will find guides to compile PMF from source (mainly intended for Linux users) and how to configure the database clients (DB2 and SQL Server) on Windows and Linux.

PMF on Linux

 PMF on Windows


Connecting to a DB2 database via the native client (Client Application Enabler, aka DB2 Connect)

Consult a search engine and look for ""ibm data server runtime client". This should take you to IBMs download area, where you can download files in the form of "ibm_data_server_runtime_client_win64_v11.1.exe" (free registration required).

Install the driver and start PMF. In the login window, select "DB2" and "<Catalog DB>"

scrshot

Click OK. This will take you to a new dialog where you can catalog new nodes and databases or catalog a database on an existing node:

scrshot


You will see all cataloged databases in PMF's connection menu. When first connecting to a DB2 database, a BIND file needs to be bound to this database. This will happen automatically.





Connecting to a DB2 database via OBDC on Windows

Generally I would recommend connecting PMF via the native DB2 client (see above) because it's faster and has a lot more options. Connecting via ODBC is recommended only if you do not want to install the native client on your system.


Setup ODBC for DB2 on Windows

This is a rather complicated affair.

Step 1:
Consult a search engine and look for "IBM Data Server Driver for ODBC and CLI".
Download the driver from IBM (free registration required). The ODBC driver is included in "IBM Data Server Driver for ODBC and CLI", disguised as Fixpack (it's a bit confusing).

What you need to download is in the form of
DSClients-XXXX-odbc_cli-XX.X.XXX.XXX-FPXXX
an example would be "DSClients-ntx64-odbc_cli-10.5.1000.898-FP010  "

You can either download the 32bit or 64 bit version.

Step 2:
Unzip the driver in a suitable directory, for example "c:\clidriver"

Navigate to "c:\clidriver\bin" and in a console window as Administrator run
db2oreg1 -i
db2oreg1 -setup
You need to be Administrator for this, else "db2oreg1" will fail without any error messages. The commands above will create the file "c:\windos\ODBCINST.INI"

Step 3:
Add the subdirectory "clidriver\bin" to your PATH environment variable

Step 4:
Reboot

Step 5:

If you installed the driver for 32bit , navigate to "\windows\SYSWOW64" and run "odbcad32.exe"
If you installed the driver for 64bit, navigate to "\windows\system32" and run "odbcad32.exe"


Click "Add" ...

db2OdbSetup1

You should see an IBM DB2 ODBC DRIVER:

db2OdbcSetup2

Select this driver, click "Finish".

Enter a "Data source name" and click "Add"




Optionally, enter a description and User/Password:



Select the "Advanced Settings" tab and click "Add"




You will need to enter a couple of values manually.



Select and edit values for "Database", "Protocol", "Hostname"  and "Port"





In the end it should look something like this:




If you have LOBs in your database, you might want to configure "LongDataCompat".

Repeat these steps for every database you want to enable for ODBC-access.

Step 6
Start PMF, select "DB2(ODBC)" in the login window and enter the login information (database, user, password).





Connecting to a DB2 database via OBDC on Linux

Generally I would recommend connecting PMF via the native DB2 client (Client Application Enabler or DB2 Connect) because it's faster and has a lot more options.
Connecting via ODBC is recommended only if you do not want to install the native client on your system.

Detailed intructions for DB2/ODBC can be found here: unixODBC

Basically, what you need to do is go to IBM ODBC driver (free registration required at some point)
then find "IBM Data Server Driver for ODBC and CLI" for your DB2 version and architecture (either 64bit or 32bit) .

Next, click on "View all" and download the driver.

Untar the downloaded file, and you will see a directory structure like "[location]/odbc_cli/clidriv"
On my systems, I copied everything under "odbc_cli/clidriv" into the directory "/opt/ibm/db2/[DB2-version]" (create it if it does not exist)

The structure should then look like this:

/opt/ibm/db2/v10.1/
/adm
/bin
/bnd
....

With newer versions of DB2, configuring ODBC comes down to these steps:
  1. Edit ".bashrc" and add these lines:

    if [ -f /home/[user]/sqllib/db2profile ]; then
    . /home/[user]/sqllib/db2profile
    fi

    DB2LIBPATH=:/opt/ibm/db2/V10.1
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$DB2LIBPATH"
    export LD_LIBRARY_PATH

    Replace [user] with the instance owner's name. If "./home/[user]/sqllib" does not exist, don't worry: For pure ODBC, you don't need it anyway.

  2. Create a file "db2cli.ini" in "/opt/ibm/db2/[DB2-Version]/cfg/". Add these lines:
    [sample]
    Database=SAMPLE
    Protocol=TCPIP
    Port=50000
    Hostname=ServerName
    UID=
    PWD=
  3. Edit the file "odbcinst.ini" and add these lines (make sure to set the correct path for 'Driver'):
    [DB2]
    Description = DB2 Driver
    Driver = /opt/ibm/db2/V10.1/lib/libdb2.so
    ##Driver = /opt/ibm/db2/V10.1/lib32/libdb2.so
    FileUsage = 1
    DontDLClose = 1
  4. Finally, edit "odbc.ini" and add these lines:
    [sample]
    Description = Test to DB2
    Driver = DB2
As always, database names must not exceed 8 characters.

To test the connection, run

isql -v sample <user> <pwd>






 

General concept

PMF consists of a GUI (GraphicalUserInterface) and currently three plugins to connect to DB2 or Sql Server.
These plugins exist for both Linux and Windows. Here is the layout:




To connect to these databases, the client system needs to be prepared.

For DB2, the CAE (ClientApplicationEnabler), sometimes called DB2 Connect or simply DB2 Client must be installed. This is easily done through the DB2 installation process.
For systems without DB2 CAE, it's possible to connect via ODBC.

For Sql Server, OBDC needs to be configured. Depending on the clients operating system (Windows or Linux), this is a bit more complicated.
Naturally, the server side needs some configuration too (user rights, open ports etc).

All this is covered in more detail in the corresponding chapters, see here.



 

Connecting to SQL Server on Linux

Obviously, SQL Server runs on Windows only. Nevertheless, it is possible to connect to SQL Server on Linux.
Microsoft is offering an ODBC driver for Linux (closed source), but I haven't tried it yet.
Instead, I'm using the tools described here. This guide should help you set up a connection to Sql Server from your Linux machine.
First, install a couple of packages: The names may vary on different systems.
Next, we need to edit three files.
These files should have been installed through the packages above. If some of them are missing, consult a search engine:
Search for your distribution and the missing file(s).

Perform the following steps as root.

Let's start with /etc/odbcinst.ini: Open it in your favourite editor and add these lines:
[ms-w7pro64]
Description= MS SQL Database
Driver = /usr/lib64/libtdsodbc.so.0
Setup = /usr/lib64/libtdsodbc.so.0
UsageCount=1
Obviously, the path on your system may vary, so make sure to enter the correct path to libtdsodbc.so.0
Again, if libtdsodbc.so.0 is missing, consult a search engine.
Also, "[ms-w7pro64]" is just an example, you can use your own marker, but make sure that you use it consistently
in the other files (see graphic below).


Next, edit /etc/odbc.ini and add these lines:
[w7-sqlsrv]
Description=TEST
Driver=ms-w7pro64
Servername=ms-w7pro64
UID=[your username, optional]
PORT=1433
TDS_Version=7.2
Database=SomeDB [default database, optional]
Currently you should use TDS version 7.2 (especially if you have XML columns in your databases) when you configure ODBC for usage with PMF. TDS 8.0 was renamed to TDS 7.2, but a lot of documentation still refers to 8.0
"w7-sqlsrv" is the string that we will use to connect to the server.
And finally, in /etc/freetds/freetds.conf or /etc/freetds.conf add these lines:
[ms-w7pro64] 
host = W7Pro64
port = 1433
client charset = UTF-8
use ntlmv2 = yes
"host" is of course the Windows machine where Sql Server runs. Try "ping [host]" to check that name resolution works.

Side note: To get name resolution working in Linux, install the packages "samba winbind" and "nss_wins".
Edit /etc/nsswitch.conf and find the line that starts with "hosts:". Add "WINS" (without quotation) at the end of this line.
Example: Simply change
hosts:  	 mdns4_minimal files nis dns myhostname mdns4
to
hosts:  	 mdns4_minimal files nis dns myhostname mdns4  wins


Here's a graphical explanation of the connections between the three ODBC files:

Make absolutely sure that there are no typos!

You can test your configuration in the command line (as root):
#osql -S w7-sqlsrv -U [username] -P [password]
If you get errors, read on.



A few notes and hints and possibly a little help:

Setting up SQL Server

You will need to configure the Windows server and Sql Server: You can use nmap (from a Linux machine) to check if the port is open:
# nmap w7pro64 -p 1433 	
(replace w7pro64 with the name of your Windows server). It should give something like
Starting Nmap 6.40 ( http://nmap.org ) at 2014-07-11 22:13 CEST
....
PORT STATE SERVICE
1433/tcp open ms-sql-s
...
The port should be marked as "open".

Tabbing

When editing the files, tabbing appears to be important
Error "no IP address found for..."
If you get an error "no IP address found for [host]", you can try editing /usr/bin/osql
Open the file (as root) and search for "no IP address found" (around line 350)
ADDRESS=$(host ${HOST} | awk '/has address/ {print $4}' | head -1)
if [ -z "${ADDRESS}" ]
then
echo "$(basename $0): no IP address found for \"${HOST}\""
# exit 1 <--- comment out this line (add "#")
fi
and comment out the line "exit 1". The code does a reverse DNS lookup and this is not really necessary.

tds_version

TDS versioning can be a bit confusing because the nomenclature changed, see here. Generally you should use TDS version 7.2 or higher (which was previously called 8.0)

Connecting

A successful connection (in a console) will look like this:
#osql -S w7-sqlsrv -U [username] -P [password]
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
trying /tmp/sql ... no
trying /tmp/sql ... no
trying /etc ... OK
checking odbc.ini files
reading /root/.odbc.ini
[w7-sqlsrv] not found in /root/.odbc.ini
reading /etc/odbc.ini
[w7-sqlsrv] found in /etc/odbc.ini
found this section:
[w7-sqlsrv]
Description=TEST
Driver=ms-w7pro64
Servername=ms-w7pro64
UID=uid
PORT=1433
TDS_Version=8.0
Database=SomeDB

looking for driver for DSN [w7-sqlsrv] in /etc/odbc.ini
found driver line: " Driver=ms-w7pro64"
driver "ms-w7pro64" found for [w7-sqlsrv] in odbc.ini
found driver named "ms-w7pro64"
"ms-w7pro64" is not an executable file
looking for entry named [ms-w7pro64] in /etc/odbcinst.ini
found driver line: " Driver = /usr/lib64/libtdsodbc.so.0"
found driver /usr/lib64/libtdsodbc.so.0 for [ms-w7pro64] in odbcinst.ini
/usr/lib64/libtdsodbc.so.0 is an executable file
Using ODBC-Combined strategy
DSN [w7-sqlsrv] has servername "ms-w7pro64" (from /etc/odbc.ini)
cannot read "/root/.freetds.conf"
/etc/freetds.conf is a readable file
looking for [ms-w7pro64] in /etc/freetds.conf
found this section:
[ms-w7pro64]
host = W7Pro64
port = 1433
tds_version = 8.0
client charset = UTF-8
use ntlmv2 = yes

osql: no IP address found for "W7Pro64"

Configuration looks OK. Connection details:

DSN: w7-sqlsrv
odbc.ini: /etc/odbc.ini
Driver: /usr/lib64/libtdsodbc.so.0
Server hostname: W7Pro64
Address:

Attempting connection as [username] ...
+ isql w7-sqlsrv [username] [password] -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+



Connecting to SQL Server via OBDC on Windows 32-bit and 64-bit systems

To connect to SQL Server with the Windows version of PMF, you need to create an ODBC datasource.
It's very important to use the correct ODBC-manager, either for 32 bit or 64 bit applications.

The standard 64-bit ODBC manager will configure connections for 64 bit applications, which is fine for PMF 64 bit.

For the 64 bit version of PMF:

Type "odbc" in the Windows-search field, this will bring up the correct ODBC-manager.

For the 32 bit version of PMF:

On 32-bit Windows, use
c:\WINDOWS\system32\odbcad32.exe
On 64-bit Windows, use
c:\windows\SysWOW64\odbcad32.exe
This will bring up the ODBC manager for either for 32 bit or 64 bit applications (they look the same):

Continue to setup your connections:

odbc01
Select either "System DSN" or "User DSN" and click "Add",
this will bring up the next menu:


odbc02

Select "SQL Server Native Client" with the highest version and click "Finish".
(Note: You may have to install "SQL Server Native Client" first)

In the next dialog you need to provide a server name:

odbc03

Give the connection a name, in this example it's simply "test".

In the next step, chose the authentication mode.
This depends on your environment, so you may have to try
out both options:


odbc05

Click "Next" as long as it takes fo finalize the assistant.

In the last step, test your configuration:

odbc06

If the test was successful, start PMF, select "SQL Server"
and select the connection you just created.


 

Accessing an MDF file on 64 bit Windows with PMF via ODBC

If you want to manipulate data in an mdf file, you will need to set up ODBC on the Windows machine first.
PMF for Windows is a 32 bit application, so on 64 bit Windows you need to start the correct ODBC manager.

The standard ODBC manager will configure connections for 64 bit applications and if you
try to use such a connection with PMF, you'll get an error along the lines of "wrong architecture".

Interlude: If you are using PMF 32 bit:

For 32 bit applications it's very important to use the correct ODBC-manager.

On 32-bit Windows, use
c:\WINDOWS\system32\odbcad32.exe
On 64-bit Windows, use
c:\windows\SysWOW64\odbcad32.exe
This will bring up the ODBC manager for 32 bit applications.

End interlude.

Continue to setup your connections:


odbc01
Select "User DSN" or "System DSN" and click "Add", this will bring up the next menu:

odbc02

Select the highest version of "SQL Server Native Client" and click "Finish".
(Note: You may have to install "SQL Server Native Client" first)

In the next step, give the connection a name and select a server.

odbc03

Hint: You may have to experiment a bit here: For the server name, try "(localdb)\v11.0" (v11.0 being the version of the SQL driver, you may have to change that) first. If this does not work, you might try "localhost" or the machine's name.
The connection name "test" is later used to connect with PMF.

Click "Next" twice to bring up this menu:

  odbc08

Enable "Change standard database to" and enter a name ("mdf_test" in this example). Do NOT use the name of an existing database here!
Enter path and name of your mdf file.


Click "next" as long as it takes to finalize the assistant. In the last step you have the option to test the new connection.

Connect PMF

If everything works, use the connection name in PMF to connect to the database in the mdf file:
Select "SqlServer" and type in "test"