Make ODBC work on Linux with Progress and Postgresql and Mono
unixODBC: http://www.unixodbc.org/odbcinst.html
Download RPM for Fedora: unixODBC-2.2.8-5.i386.rpm
(might require libtool-libs
and ncurses)
/etc/odbc.ini:
[my_psql]
Description = Test to Postgres
Driver = PostgreSQL
Trace = Yes
TraceFile = sql.log
Database = mydb
Servername = 10.10.1.40
UserName =
Password =
Port = 5432
Protocol = 8.0
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
[my_progress]
Driver=Progress
Description = Test to Progress
DatabaseName=mydb
PortNumber=2071
HostName=10.10.1.40
LogonID=
Password=
APILevel=1
ConnectFunctions=YYN
CPTimeout=60
DriverODBCVer=03.60
FileUsage=0
SQLLevel=0
UsageCount=1
ArraySize=50
DefaultLongDataBuffLen=2048
DefaultIsolationLevel=REPEATABLE READ
StaticCursorLongColBuffLen=4096
/etc/odbcinst.ini:
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[Progress]
Description = ODBC for Progress
Driver = /usr/local/progress/odbc/lib/pgpro915.so
#Driver = /usr/local/progress/odbc/lib/libpgmfront.so
#Setup = /usr/local/progress/odbc/lib/libodbcinst.so
FileUsage = 1
Test program:
// example from http://mono-project.com/contributing/odbc.html
using System;
using System.Data;
using System.Data.Odbc;
public class Test
{
string connectionString, sql;
public void testPostgresql()
{
System.Console.WriteLine("Testing Postgresql");
connectionString =
"DSN=my_psql;" +
"UID=myusername;" +
"PWD=mypassword";
sql =
"SELECT * FROM a_ledger";
}
public void testProgress()
{
System.Console.WriteLine("Testing Progress");
connectionString =
"DSN=my_progress;" +
"UID=myusername;" +
"PWD=mypassword";
sql =
"SELECT * FROM pub.a_ledger";
}
public void testConnection()
{
try
{
IDbConnection dbcon;
dbcon = new OdbcConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
int a_ledger_number_i = (int) reader["a_ledger_number_i"];
Console.WriteLine("Ledger Nr: " +
a_ledger_number_i );
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
catch(Exception ex)
{
System.Console.WriteLine("Error: " + ex.Message);
}
}
public static void Main(string[] args)
{
Test test = new Test();
test.testPostgresql();
test.testConnection();
test.testProgress();
test.testConnection();
}
}
make sure /var/lib/pgsql/data/pg_hba.conf is configured correctly (for localhost?)
mcs dbodbc.cs -r:System.Data.dll
LD_LIBRARY_PATH=/usr/lib:/usr/local/progress/odbc/lib:/usr/local/progress/lib
export LD_LIBRARY_PATH
export LD_ASSUME_KERNEL=2.4.1 # to avoid error: " version GLIBC_2.0 not defined in file libc.so.6 with link time reference"
export LANG=en_US
export ODBCINI=/etc/odbc.ini # to resolve Error: [unixODBC][DataDirect-Technologies][ODBC PROGRESS driver]No Host Name.
mono dbodbc.exe
ODBC on windows
change c:/program files/mono/etc/mono/config
remove line
<dllmap dll="odbc32.dll" target="libodbc.so" />
With MS.Net 1.1 there was a problem that I got that annoying message:
System.Security.SecurityException: Request failed.
I finally found the solution here: The .NET Framework Data Provider for ODBC currently requires FullTrust permission.
That meant, I had to go to Start/Settings/Control Panel/Administrative
Tools/Microsoft .NET Framework 1.1 Configuration/Runtime Security
Policy;
I don't exactly understand all the details, but when I change the
Machine/Code Groups/All_Code property Permission Set from Nothing to
Fulltrust, it works.