Installing unixODBC

Installing unixODBC,第1张

概述CobolScript Professional for Linux, FreeBSD, and SunOS. Overview CobolScript Professional uses the ODBC specification to connect to data sources. You must install unixODBC in order to use CobolScript CobolScript Professional for linux,FreeBSD,and SunOS.


OvervIEw

CobolScript Professional uses the ODBC specification to connect to data sources. You must install unixODBC in order to use CobolScript Professional for linux,or SunOS. unixODBC has a GUI component,but it is not required to use CobolScript Professional. If you are running linux with a kernel older than 2.2.12,you should not install the GUI.


Installing unixODBC without the GUI

Step 1. Download unixODBC from here .
Step 2. copy the unixODBC*.tar.gz to /usr/local
Step 3. gunzip unixODBC*.tar.gz
Step 4. tar xvf unixODBC*.tar
Step 5. cd unixODBC*
Step 6. ./configure --enable-gui=no
Step 7. make
Step 8. make install
Step 9. cd /etc
Step 10. Edit the file ld.so.conf and add "/usr/local/lib" to it.
Step 11. ldconfig (Running this command will allow your system to see the unixODBC shared librarIEs)
Step 12. Add the unixODBC drivers that you want to use to the /usr/local/etc/odbcinst.ini file.
Here is an example of an odbcinst.ini file.[MysqL]Description     = MysqL DriverDriver          = /usr/local/lib/libmyodbc.soSetup           = /usr/local/lib/libodbcmyS.sofileUsage       = 1[Postgresql]Description     = Postgresql DriverDriver          = /usr/local/lib/libodbcpsql.soSetup           = /usr/local/lib/libodbcpsqlS.sofileUsage       = 1
Step 13. Add your Data Source names to /usr/local/etc/odbc.ini Here is an example of a odbc.ini with two Data Source names - Postgresql and MysqL
[Postgresql]Description		= PostgresqlDriver			= PostgresqlTrace			= NoTracefile		= Database		= testServername		= localhostUsername		= postgresPassword		= mypassPort			= 5432Protocol		= 6.4Readonly		= NoRowVersioning		= NoShowSystemtables	= NoShowOIDColumn		= NoFakeOidindex		= NoConnSettings		= [MysqL]Description		= MysqLDriver			= MysqLTrace			= YesTracefile		= /tmp/MysqL.odbc.logServer			= localhostPort			= 3306Database		= deskwareUser			= rootPassword		= mypass



Installing unixODBC with the GUI

Step 1. Download QT Free Edition from here.
Step 2. copy or move the qt-2.0.2.tar.gz file to /usr/local
Step 3. gunzip qt-2.0.2.tar.gz
Step 4. tar -xvf qt-2.0.2.tar
Step 5. mv qt-2.0.2 qt
Step 6. Set the following environment variables in your .profile or .login depending on the shell you are using.
    In .profile (if your shell is bash,ksh,zsh or sh),add the    following lines:        QTDIR=/usr/local/qt        PATH=$QTDIR/bin:$PATH        if [ $MANPATH ]        then                MANPATH=$QTDIR/man:$MANPATH        else                MANPATH=$QTDIR/man        fi        if [ $LD_liBRARY_PATH ]        then                LD_liBRARY_PATH=$QTDIR/lib:$LD_liBRARY_PATH        else                LD_liBRARY_PATH=$QTDIR/lib        fi        liBRARY_PATH=$LD_liBRARY_PATH        if [ $CPLUS_INCLUDE_PATH ]        then                CPLUS_INCLUDE_PATH=$QTDIR/include:$CPLUS_INCLUDE_PATH        else                CPLUS_INCLUDE_PATH=$QTDIR/include        fi        export QTDIR PATH MANPATH LD_liBRARY_PATH liBRARY_PATH        export CPLUS_INCLUDE_PATH    In .login (in case your shell is csh or tcsh),add the following lines:        if ( ! $?QTDIR ) then            setenv QTDIR /usr/local/qt        endif        if ( $?PATH ) then            setenv PATH $QTDIR/bin:$PATH        else            setenv PATH $QTDIR/bin        endif        if ( $?MANPATH ) then            setenv MANPATH $QTDIR/man:$MANPATH        else            setenv MANPATH $QTDIR/man        endif        if ( $?LD_liBRARY_PATH ) then            setenv LD_liBRARY_PATH $QTDIR/lib:$LD_liBRARY_PATH        else            setenv LD_liBRARY_PATH $QTDIR/lib        endif        if ( ! $?liBRARY_PATH ) then            setenv liBRARY_PATH $LD_liBRARY_PATH        endif        if ( $?CPLUS_INCLUDE_PATH ) then            setenv CPLUS_INCLUDE_PATH $QTDIR/include:$CPLUS_INCLUDE_PATH        else            setenv CPLUS_INCLUDE_PATH $QTDIR/include        endif            After you have done this,you will need to login again,or    re-source the profile before continuing,so that at least $QTDIR    is set.  The installation will give an error message and not    proceed otherwise.

Step 7. cd qt
Step 8. ./configure
Step 9. make
Step 10. Download unixODBC from here.
Step 11. copy or move the unixODBC*.tar.gz to /usr/local
Step 12. gunzip unixODBC*.tar.gz
Step 13. tar xvf unixODBC*.tar
Step 14. cd unixODBC*
Step 15. ./configure
Step 16. make
Step 17. make install
Step 18. cd /etc
Step 19. Edit the file ld.so.conf and add "/usr/local/lib" to it.
Step 20. ldconfig (Running this command will allow your system to see the unixODBC shared librarIEs)
Step 21. Add the unixODBC drivers that you want to use to the /usr/local/etc/odbcinst.ini file.
Here is an example of an odbcinst.ini file.[MysqL]Description	= MysqL DriverDriver		= /usr/local/lib/libmyodbc.soSetup		= /usr/local/lib/libodbcmyS.sofileUsage	= 1[Postgresql]Description	= Postgresql DriverDriver		= /usr/local/lib/libodbcpsql.soSetup		= /usr/local/lib/libodbcpsqlS.sofileUsage	= 1
Step 22. Add your Data Source names to /usr/local/etc/odbc.ini Here is an example of a odbc.ini with two Data Source names - Postgresql and MysqL
[Postgresql]Description		= PostgresqlDriver			= PostgresqlTrace			= NoTracefile		= Database		= testServername		= localhostUsername		= postgresPassword		= mypassPort			= 5432Protocol		= 6.4Readonly		= NoRowVersioning		= NoShowSystemtables	= NoShowOIDColumn		= NoFakeOidindex		= NoConnSettings		= [MysqL]Description		= MysqLDriver			= MysqLTrace			= YesTracefile		= /tmp/MysqL.odbc.logServer			= localhostPort			= 3306Database		= deskwareUser			= rootPassword		= mypass



unixODBC non-GUI Component

isql is a command line tool that allows you to connect to your data sources,send sql commands to the data source,and receive results from the data source. You can execute it by tyPing "/usr/local/bin/isql ".




unixODBC GUI Components

ODBCConfig is a tool is designed to allow you to easily setup a Data Source name. You can execute it by tyPing "/usr/local/bin/ODBCConfig".



DataManager is a graphical tool for exploring data sources. You can execute it by tyPing "/usr/local/bin/DataManager".




unixODBC Drivers

unixODBC comes with drivers for Minisql,Postgresql,News Server,and SQI. A MysqL unixODBC driver can be found here.


Resources for unixODBC Drivers

Company unixODBC Driver Data Source
Postgresql
http://www.postgresql.org
Postgresql Driver included with unixODBC Postgresql
T.C.X DataKonsult AB
Fax: +46-8-7296905
http://www.mysql.com/download_myodbc.html
MyODBC Driver for unixODBC MysqL
YARD Software GmbH
Tel.: +49 221 98664-0 Fax.: +49 221 98664-99
http://www.yard.de
YARD unixODBC Driver YARD-sql
Hughes TechnologIEs
Fax: +61 7 5529 2299
http://www.Hughes.com.au/
Minisql Driver included with unixODBC Minisql
SQI Text file Driver
sql unixODBC Driver for Text files Text files
Ke Jin's Net News ODBC Driver
Internet News Server Driver included with unixODBC Internet News Server
Easysoft
Tel: +44 (0) 113 222 0400 Fax: +44 (0) 113 222 0500
http://www.easysoft.com/
Easysoft's ODBC-ODBC BrIDge ODBC-ODBC



Example sql Statements with CobolScript

             CREATE table                                                                         exec sql                                                                            create table customer                                                            ( firstname   varchar(20),lastname    varchar(20),description varchar(50))                                                    end-exec.                                                                                                                                                     INSERT                                                                               exec sql                                                                            insert into customer                                                             values (:customer-first-name,:customer-last-name,:customer-description)                                                end-exec.                                                                                                                                                     DELETE                                                                               exec sql                                                                             delete from customer                                                             where firstname = 'dean6'                                                    end-exec.                                                                                                                                                     UPDATE                                                                               exec sql                                                                            update customer                                                                  set description = 'update test again'                                            where firstname = :customer-first-name and                                             lastname  = :customer-last-name                                         end-exec.                                                                                                                                                     SELECT                                                                               exec sql                                                                             select firstname,lastname,description                                      into :customer-first-name,:customer-description                                                       from customer                                                                    where firstname = 'dean8   '                                                 end-exec.                                                                                                                                                     DECLARE                                                                                 exec sql                                                                              declare cust_cursor cursor for                                                   select firstname,dollar_amount                                                  from customer                                                                    order by firstname                                                          end-exec.                                                                                                                                               OPEN            exec sql open cust_cursor end-exec. CLOSE           exec sql close cust_cursor end-exec. FETCH exec sql fetch relative :row-position cust_cursor into :customer-first-name,:customer-dollar-amount end-exec. FETCH Syntax: FETCH {NEXT | PRIOR | FirsT | LAST | absolute {int-constant | host-constant } | RELATVIE {int-constant | host-constant }} cursor-name INTO host-variable [,...] COMMIT exec sql commit end-exec. RolLBACK exec sql rollback end-exec.             



A Sample CobolScript Program using a MysqL Database

       1 misc.          5 data-source-name       pic x(50).          5 user-ID                pic x(10).          5 password               pic x(10).          5 return-code            pic s9(05).          5 row-position           pic s9(05).          5 formatted-balance      pic $$$,$$$.99.       1 customer-table.          5 customer-first-name    pic x(20).          5 customer-last-name     pic x(20).          5 customer-description   pic x(70).          5 customer-balance       pic 9(06).99.       1 sql-return-codes.          5 sqlstate               pic x(05).          5 sqlnativeerror         pic s9(06).          5 sqlerrormessage        pic x(500).          5 sqlstatement           pic x(500).       main.           perform connect_to_database.           perform create_table.           perform alter_table.           perform create_index.           perform insert_into_table.           perform select_from_table.           perform build_cursor.           perform update_table.           perform delete_from_table.           perform drop_index.           perform drop_table.           perform disconnect_from_database.           stop run.       connect_to_database.           move `MysqL`      to data-source-name.           move `testuser`   to user-ID.           move `testpass`   to password.           opendb using      data-source-name                             user-ID                             password                             return-code.       create_table.           exec sql              create table customer               (firstname   varchar(20),description varchar(70)  )           end-exec.       alter_table.           exec sql              alter table customer add                balance decimal(6,2)            end-exec.       create_index.           exec sql              create index cust_index on customer (firstname)           end-exec.       insert_into_table.           exec sql              commit           end-exec.           move `John`  to customer-first-name.           move `Doe`  to customer-last-name.           move `Senior Director at Acme Software House` to customer-description.           move 99.95 to customer-balance.           exec sql              insert into customer              values (:customer-first-name,:customer-description,:customer-balance )           end-exec.           exec sql              insert into customer              values ('Jane','Doe','Senior Programmer',123.95 )           end-exec.           exec sql              insert into customer              values ('Matt','Junior Programmer',23.00 )           end-exec.           exec sql              insert into customer              values ('Charles','GEM Programmer',199.99 )           end-exec.           exec sql              commit           end-exec.           exec sql              insert into customer              values ('Jason','Programmer',99.00 )           end-exec.           exec sql              rollback           end-exec.       select_from_table.           exec sql               select firstname,description,balance               into :customer-first-name,:formatted-balance               from customer               where lastname = 'Doe' and                     firstname = 'Charles'           end-exec.           if sqlnativeerror = 0 then              display `select into statement successful`              display `firstname: ` & customer-first-name              display `lastname: ` & customer-last-name              display `description: ` & customer-description              display `balance: ` & formatted-balance           else              display `select into statement Failed`              display `sql-return-codes: ` & sql-return-codes           end-if.       build_cursor.           exec sql                declare cust_cursor cursor for                select firstname,balance                from customer               order by balance           end-exec.        open_cursor.           exec sql                open cust_cursor           end-exec.        fetch_cursor.           display ``.           display `firstname            lastname                balance`.           display `----------------------------------------------------`.           exec sql              fetch last cust_cursor              into :customer-first-name,:formatted-balance           end-exec.           if sqlnativeerror = 0 then              display customer-first-name & ` ` & customer-last-name & ` ` & formatted-balance           end-if.           move -1 to row-position.           exec sql              fetch relative :row-position  cust_cursor              into :customer-first-name,:formatted-balance           end-exec.           if sqlnativeerror = 0 then              display customer-first-name & ` ` & customer-last-name & ` ` & formatted-balance           end-if.           perform fetch-data-from-database              until sqlnativeerror = 100.           display `----------------------------------------------------`.           display ``.           exec sql                close cust_cursor           end-exec.           if sqlnativeerror = 0 then              display `close cursor successful`           else              display `close cursor Failed`              display `sql-return-codes: ` & sql-return-codes           end-if.       fetch-data-from-database.           exec sql              fetch next cust_cursor              into :customer-first-name,:formatted-balance           end-exec.           if sqlnativeerror = 0 then              display customer-first-name & ` ` & customer-last-name & ` ` & formatted-balance           end-if.       update_table.           move `Doe` to customer-last-name.           exec sql              update customer              set lastname = 'Jones'              where firstname = 'Matt' and                    lastname  = :customer-last-name           end-exec.           exec sql              commit           end-exec.       delete_from_table.           exec sql               delete from customer               where firstname = 'Charles' and lastname = 'Doe'           end-exec.           exec sql              commit           end-exec.       drop_index.           exec sql              drop index cust_index on customer           end-exec.       drop_table.           exec sql              drop table customer           end-exec.       disconnect_from_database.           closedb using return-code.
@H_247_301@ 总结

以上是内存溢出为你收集整理的Installing unixODBC全部内容,希望文章能够帮你解决Installing unixODBC所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1181157.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存