Check out DBI::Proxy

Here is how I implemented Linux->Windows ODBC integration using DBI::Proxy

1) install all of the necessary modules on Windows machine (get off CPAN)
      -Net-Daemon-0.31
      -PlRPC-0.2012

you will have to use nmake to compile the modules but they are a snap 
(nmake15.exe on Microsoft's site)

2) make a C:\tmp [/tmp] directory (needs to be this - tmp!)
3) run from a DOS prompt:
        dbiproxy --debug --logfile log --localport 3333
          this script comes with DBI
          only really seems to print to screen not to log file

Now from your Linux box (make sure you have DBI installed):

          #!/usr/bin/perl

         # We created a DSN called MYDSN in the Windows control panel ODBC 
dialog

        my $dsn_name = "MYDSN";
        my $dsn              = "dbi:ODBC:$dsn_name";
        my $uid               = 'username';
        my $pass           = 'password';
        my $hostname  = '192.168.0.4';
        my $port              = 3333;
        my $tablename  = 'Customers';

        my $proxy          = "hostname=$hostname;port=$port";
        my $dbh             = DBI->connect("dbi:Proxy:$proxy;dsn=$dsn", 
$uid, $pass);

        my $request    = "SELECT * FROM \"$tablename"";

        my $sth        = $dbh->prepare($request);
        my $res        = $sth->execute();

       while(my $r = $sth->fetchrow_hashref) {
            print"$_ = $r->{$_}\n" for sort keys %$r;
            print"******\n";
            <STDIN>;
       }

Here is how to install a service:

Installing the Service

A) Install the attached files into the system32 directory
       -instsrv.exe (installs services)
       -srvany.exe (allows applications to run as a service)

B) Install your service:

       INSTSRV [Service_name] c:\winnt\system32\srvany.exe

C) Configure the service via the Services Applet (in Control Panel)
      using the "Startup..." button/dialog (not really much to do here
      besides manual or automatic - which we all know which one we want ;-)

Specifying the application

A) Run the registry editor (regedt32.exe)

B) under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[Service_name]
          -create a 'Parameters' key  (looks like a directory when added)

C) under the 'Parameters' key, create a key value 'Application' of type 
REG_SZ and specify
       the full path of the executable (or batch file) including the extension

           Application: REG_SZ: c:\dbi_prox.bat

Check out the readme.wri  that is in the srvany_x86 zip file for complete 
instructions


At 08:16 AM 11/9/00 -0600, you wrote:
>I am trying to access access Microsoft SQL server on NT from Apache Server
>under Linux,
>Can some one give me a direction, how/where to looking into it?
>
>Appreciate for any help
>
>PC Wang
>
>-----Original Message-----
>From: clayton cottingham [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, November 08, 2000 4:11 PM
>To: Greg Cope
>Cc: Jason Liu; [EMAIL PROTECTED]
>Subject: Re: database access
>
>
>Greg Cope wrote:
> >
> > Jason Liu wrote:
> > >
> > > Is Apache::DBI absolutely necessary if you want to establish persistent
> > > database connection per child?
> >
> > No you can write your own (its open source remember ;-) but why bother -
> > standing on the shoulders of giants etc ....
> >
> > Greg
> >
> > >
> > > Thanks,
> > >
> > > Jason
> > >
> > > > -----Original Message-----
> > > > From: David Hodgkinson [mailto:[EMAIL PROTECTED]]
> > > > Sent: Monday, November 06, 2000 5:10 AM
> > > > To: Jason Liu
> > > > Cc: [EMAIL PROTECTED]
> > > > Subject: Re: database access
> > > >
> > > >
> > > > "Jason Liu" <[EMAIL PROTECTED]> writes:
> > > >
> > > > > In general, how should database connections be handled between
> > > > parent and
> > > > > child processes?  Can you establish database connections from within
>a
> > > > > handler?
> > > >
> > > > Absolutely. And using Abache::DBI caches the connection handle.
> > > >
> > > > --
> > > > Dave Hodgkinson,                             http://www.hodgkinson.org
> > > > Editor-in-chief, The Highway Star           http://www.deep-purple.com
> > > >       Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
> > > >   -----------------------------------------------------------------
> > > >
>
>
>
>the problem can also be resolved depending on the type of db used
>
>yes you can program your own levels of persistence
>
>finding a database that can do this for you can be a great help.
>
>postgres for instance has concurrent locking , on table , row and or
>column.
>
>using its Pg module instead of DBD::Pg and DBI
>
>handles the opening and closing of the connections too ;)
>
>making your own wrapper module ito interface with DBI or PG is a good
>thing to do as well
>
>i usually use something that does all the basic statement handling and
>db connect strings
>
>then i can just
>use PGForm; #my module to go to Pg
>PGform($db,$user,$password,$sqlstatement);
>
>and
>if a select returns a array of arrays
>
>else if insert update delete etc returns ok or error


Reply via email to