PDA

View Full Version : New to *nix - in an odbc nightmare


TomBodet
2006-05-10, 08:02 AM CDT
I freely admit, I have no clue what I'm doing. :confused:

I have a FC5 box set up and running an Oracle 10g instance. On a WinXP box I have a Sybase database. When I had Oracle running on Windows, I was able to create an ODBC entry and use Oracle's heterogeneus connections to link the databases and simply run SQL to copy data. I have those scripts saved.

Now there's a bloody head-print in the wall in the server room next to the Fedora box.

I've downloaded FreeTDS, tried the compilation instructions, tried using ODBCConfig and just can NOT for the life of me figure out what I'm doing wrong.

I would swear that a week ago I was able to do a make on the install....but it's not working today. I've never seen FreeTDS get installed to the folder they say it's supposed to be in and probably because I'm an idiot. Now when I try a make I get exit status 1. Running the ./config appears to work...but I can't follow up.

I'm begging for help at this point. Explain it like I'm a 5yr old, because that's how stupid I feel... What am I missing?

giulix
2006-05-10, 08:20 AM CDT
I think I could give it a try... where do I download it from ? Which version?

TomBodet
2006-05-10, 09:41 AM CDT
ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

The site is www.freetds.org. Above is the link to their current stable release.

Thanks.

brunson
2006-05-10, 10:05 AM CDT
Were you not able to get it to compile? Dries has a FC5 rpm for freetds. Aside from that, I was just able to compile it with no problems. What exactly is the problem you're having? And, more academically, why bother adding a layer of obfuscation like TDS to access Oracle? Why not use the native Oracle client? Will you eventually have to access a SQLServer instance?

TomBodet
2006-05-10, 10:20 AM CDT
I'm not going to use this to access Oracle, I need it in order to connect to a Sybase database on another machine. This is a migration from Sybase to Oracle where I already have a working script using Oracle's heterogeneus database connections and a database link to pull the data over.

A week ago I thought I was able to do a make on the code but I cannot find the install directory so I went to do it again. Now I'm getting an error when trying to run make and I don't understand linux enough to know where to start.

I've tried using the ODBCConfig window that I think comes with unixODBC which is included in the FreeTDS distribution but I cannot set up a driver. FreeTDS was supposed to have a generic driver that would talk to Sybase, but I can't find it (let alone knowing what it's called) because I haven't seen the install directory show up where it's supposed to based on the docs. It should be /usr/local/freetds. It's not there. On top of it, all the Sybase installs we have are on Windows, so I can't just pull the driver out of a current install.

TomBodet
2006-05-10, 01:04 PM CDT
Update: I tried the freetds rpm and managed to get something back from tsql so I know I can get that far.

My probem is, this is using the non-dsn connection. I still need to configure an ODBC dsn so Oracle can create the database link with it. As far as I understand, I can't do that in my current state. The setup for ODBC according to freetds, needs libtdsodbc.so which I cannot find on this system. That was one reason I was trying to compile because I thought it was part of the source.

This also goes back to the fact I don't have the /usr/local/freetds directory. That's supposedly where it all should get installed. But the rpm doesn't appear to have done that.

brunson
2006-05-10, 01:50 PM CDT
clotho(~)$ rpm -ql freetds | grep libtdsodbc
/usr/lib/libtdsodbc.so.0
/usr/lib/libtdsodbc.so.0.0.0
What can't find libtdsodbc? Try creating a sym link:
ln -s /usr/lib/libtdsodbc.so.0 /usr/lib/lib/tdsodbc.so

TomBodet
2006-05-10, 02:10 PM CDT
That first code you gave me... That's one of my biggest problems. I have no clue what that is.

I did a find for libtdsodbc and found nothing.

But using your code I found the directory and found:
libtdsodbc.so.0
libtdsodbc.so.000

I created the link and added an entry into odbc.ini in /etc.

Any clue how to test this?

giulix
2006-05-11, 03:11 AM CDT
All my attempts at installing Sybase on a FC4 box wrecked miserably: "00:00000:00000:2006/05/11 10:34:33.15 kernel The configuration area in device '/home/sybase/data/master.dat' appears to be corrupt. The server cannot continue and will shut down" :(
Anyway, I was able to build freetds too with the archive provided on a FC5 box: everything gets installed in /usr/local.

TomBodet
2006-05-11, 05:55 AM CDT
Anyway, I was able to build freetds too with the archive provided on a FC5 box: everything gets installed in /usr/local.

Is there a specific location you should copy the code to in order to compile? Are there environment variables that I should have? I don't understand why this doesn't work for me now.

./configure - works
make - fails exit code 1
make install - fails exit code 1

Those are the commands listed in the readme, did you do anything different?

giulix
2006-05-11, 06:17 AM CDT
Nope to all of your questions. If you could post the output of the make command here, especially the first error reported, that would be very helpful. I am pretty sure you're only missing some compilation tool or something really trivial..

TomBodet
2006-05-11, 06:55 AM CDT
[root@logsvr2 freetds]# make
cd . && automake --gnu --include-deps Makefile
aclocal.m4:49: error: m4_defn: undefined macro: _m4_divert_diversion
autoconf/oldnames.m4:113: AM_PROG_INSTALL is expanded from...
aclocal.m4:49: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
automake: autoconf failed with exit status: 1
make: *** [Makefile.in] Error 1

I just realized that it's complaining about the missing macro. Is that supposed to be in FC5 or is that something that the configure should have created?

I reran the ./configure and it looks like it comes out all okay.

giulix
2006-05-11, 08:44 AM CDT
Mmmmmh.... never seen that one before: I suggest you do a

yum groupinstall "Development Tools"

just to be on the safe side...

TomBodet
2006-05-11, 09:13 AM CDT
Didn't help. It did update a few packages, but I'm still getting the error.

After some searching it seems to be a problem with autoconf. Not knowing exactly what that is doesn't help me though. I'm still searching, maybe there's an update I need for it or a change to the script is needed?

TomBodet
2006-05-11, 09:36 AM CDT
Out of curiosity I downloaded the tgz again to a new location. It all installed fine. =/

Now I'm trying to run isql with the odbc entry I created and am getting on a verbose try:

[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect

Here's the odbc.ini:[ODBC Data Sources]
LOG = Sybase JDBC Server

[LOG]
Driver = /usr/local/freetds/lib/libsybdb.so
Description = hope this works
Trace = No
Server = BOX2
Database = LOG
Port = 2638
TDS_Version = 4.2

[Default]
Driver = /usr/local/freetds/lib/libtds.so

All I'm typing is "isql LOG"

TomBodet
2006-05-22, 06:37 AM CDT
Bump.

Still haven't figured this out and according to the docs on unixODBC and freetds, to do a DSN connection to Sybase I need a driver called libtdsodbc.so which isn't in the freetds directory. On unixODBC it talks about other configure settings: ./configure --with-tdsver=8.0 --with-unixodbc=/usr/local But this fails, well, the configure works, the following make is what fails.

Here's where it seems to fall apart: gcc -DHAVE_CONFIG_H -I. -I. -I../../include -I../../include -D_FREETDS_LIBRARY_SOUR CE -DUNIXODBC -D_REENTRANT -D_THREAD_SAFE -DDEBUG=1 -Wall -Wstrict-prototypes -Wmiss ing-prototypes -Wno-long-long -g -O2 -MT blk.lo -MD -MP -MF .deps/blk.Tpo -c blk.c -fPIC -DPIC -o .libs/blk.o
blk.c: In function '_blk_build_bulk_insert_stmt':
blk.c:1013: warning: pointer targets in passing argument 1 of 'strlen' differ in sig nedness
blk.c:1018: warning: pointer targets in passing argument 1 of 'strcpy' differ in sig nedness
blk.c:1018: warning: pointer targets in passing argument 2 of 'strcpy' differ in sig nedness After that it's a long list of failures.

giulix
2006-05-22, 07:02 AM CDT
Those are just warnings, you should look for "error:" strings... Generally the first one is the one that causes the whole make script to fall apart.

TomBodet
2006-05-22, 07:15 AM CDT
Whooops, was looking at the wrong thing when I copied.

gcc -DHAVE_CONFIG_H -I. -I. -I../../include -I../../include -I/usr/local/include -D _FREETDS_LIBRARY_SOURCE -DUNIXODBC -D_REENTRANT -D_THREAD_SAFE -DDEBUG=1 -Wall -Wstr ict-prototypes -Wmissing-prototypes -Wno-long-long -g -O2 -MT odbc.lo -MD -MP -MF .d eps/odbc.Tpo -c odbc.c -fPIC -DPIC -o .libs/odbc.o
In file included from odbc.c:55:
../../include/tdsodbc.h:26:17: error: sql.h: No such file or directory
../../include/tdsodbc.h:27:20: error: sqlext.h: No such file or directory
../../include/tdsodbc.h:28:22: error: odbcinst.h: No such file or directory
In file included from odbc.c:55:
../../include/tdsodbc.h:73: error: expected specifier-qualifier-list before 'SQLRETU RN'
../../include/tdsodbc.h:104: error: expected specifier-qualifier-list before 'SQLSMA LLINT'
../../include/tdsodbc.h:116: error: expected specifier-qualifier-list before 'SQLUIN TEGER'

giulix
2006-05-22, 09:28 AM CDT
I am not familiar with Sybase. What I can infer from those errors is that it's missing some standard headers from a database installation. I use Postgres (a bit) and Oracle (a lot) and both install those headers in different places. You should try to find out where your client database installation installed those files and feed them to the make script, so that it can find them. I am sorry I can't help you more, but my attempt at installing Sybase was unsuccessful. Hopefully somebody who has experience with Sybase will turn up to shed some light onto this, or you can try some Sybase forums on how to compile the package on linux.

TomBodet
2006-05-22, 09:54 AM CDT
I was unaware that this required Sybase to be installed.

The entire purpose of this was simply to get a Fedora box to connect to another box (WinXP) running a Sybase server in order to copy data from that Sybase system into the Oracle database on the Fedora system.

My understanding of the freetds info was that it came with a driver that was able to connect to Sybase which was why I bothered in the first place. All the Sybase installs my company owns are Windows based so that won't work.

...I'm very confused.

giulix
2006-05-22, 12:21 PM CDT
I can understand that. The fact is, if you are going to install this ODBC driver from source, you probably need to set up the environment on Fedora for that. Since this is a driver for Sybase, I reckon it needs the Sybase header files and libraries to compile properly. Usually (with Oracle and Postgres this is the case), you can install a client version to access the database, compile client programs, etc. During my attempt to install Sybase I didn't notice any client-only install option, though. Tomorrow, I'll have another look: we may be lucky and get away with that...

TomBodet
2006-05-22, 12:40 PM CDT
That would be most appreciated giulix, thank you.

giulix
2006-05-23, 01:59 AM CDT
Actually you can install the client onto FC5. I downloaded ASE for Linux from Sybase, fired it up, selected the Developer Edition, accepted the EULA, entered a directory in my home path, selected Custom Installation, deselected Sybase Servers, Selected ASE ODBC driver in ASE Data Providers and left the other options as they were. Then left Configure Unified Agent selected and Custom Configure Unified Agent deselected.
Unfortunately I couldn't test it, because I don't have a Sybase database, so I cannot really tell whether it could be the solution to your problem. Worth a try though, imo...

TomBodet
2006-05-23, 05:57 AM CDT
You know, I never noticed the link for linux on Sybase's site....sheesh.

Downloading now.

TomBodet
2006-05-23, 11:37 AM CDT
I've never been more frustrated in my whole life.

Downloaded & installed Sybase but am no closer to anything. I cannot connect with isql, can't make freetds with the configure option suggested and can't understand why anyone would go through this much hassle to set up something on linux when it would take 10 minutes on Windows.

giulix
2006-05-24, 02:25 AM CDT
I was able to compile freeTDS after installing unixodbc (http://www.unixodbc.org) (./configure --enable-gui=no), by providing /usr/local as the odbc directory

./configure --with-unixodbc=/usr/local

TomBodet
2006-05-26, 10:39 AM CDT
Progress!

Okay it's a baby step, but damn it's forward movement.

First, thank you giulix for telling me to install unixodbc.

The funny part? FreeTDS has been installing the one library it keeps touting as Sybase compatible in /usr/local/lib, not in ../freetds. There were a few copies of it laying there.

Now, I can't seem to get isql to connect. I've even been able to use ODBCConfig and create a driver based on the above file location and even configure a DSN with it, but I'm still getting a could not sqlconnect when trying isql. I've also tried creating the database link in Oracle and am getting "could not resolve the connect identifier specified" so I believe I'm still not making any connection.

Is there another way I can test this DSN?

Edit: The verbose error from isql is:[FreeTDS][SQL Server]Unable to connect to data source

I'm seeing that the FreeTDS docs state compatability with Sybase SQL Anywhere to use version 5.0. (http://www.freetds.org/userguide/choosingtdsprotocol.htm) So trying a ./configure --with-tdsver=5.0 --with-unixodbc=/usr/local runs, but the make of that configure fails:cd . && automake --gnu --include-deps Makefile
aclocal.m4:49: error: m4_defn: undefined macro: _m4_divert_diversion
autoconf/oldnames.m4:113: AM_PROG_INSTALL is expanded from...
aclocal.m4:49: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
automake: autoconf failed with exit status: 1
make: *** [Makefile.in] Error 1

I've also tried it using version=4.2 and get the same error when running the make.