如何用ODBC连接postgresql呢,谁能指教下,要是能有个最简单的例子就好了。
谢谢了。

解决方案 »

  1.   

    通过ODBC连接Postgresql
    适用于:RedHat/SuSE Linux: Version 6.xApplix: Version 5.0Postgresql: Version 6.5.3
    以下的安装的大纲是安装Postgresql在RedHat或者SuSE Linux所必须的. 为了更新Postgresql和更一步的参考资料,请访问www.postgresql.org . 为了完整考虑, 这个文挡解释怎样编译原始资料Applixware安装在 /opt/applix Postgresql 安装在/usr/local/Postgresql 。 你用"root"用户登陆:
    1. 下载PostgresqlA."ftp://ftp.postgresql.org/pub/"B. 下载并保存为"postgresql-6.5.3.tar.gz"到你的home目录2. 分发安装PostgresqlA. 创建一个用户'postgres' 和一个组'postgres' 如果他们都不存在于你的系统中. 这个用户'postgres'的home目录是 /var/lib/pgsql.B. 把下载的文件移到 /var/lib/pgsqlC. 检查flex 和Postgres之间的兼容性:$ flex --version如果flex命令没有找到,你就可能不需要它. 如果版本是2.5.2 or 2.5.4 或者更大. 如果是2.5.3 在2.5.2之前,你将也需要升级 flex. 从这里可以下载ftp://prep.ai.mit.edu/pub/gnu/flex-2.5.4.tar.gz.
    D. 创建新得安装目录
    $ su$ cd /usr/src$ mkdir pgsql$ chown postgres:postgres pgsql$ cd /usr/local$ mkdir pgsql$ chown postgres:postgres pgsql$ exit
    E. 解压安装文件$ cd /usr/src/pgsql$ gunzip -c ~/postgresql-v6.5.3.tar.gz | tar xvf -
    F. 配置 /usr/local/pgsql:$ cd /usr/src/pgsql/posgresql-6.5.3/src$ ./configure --prefix=/usr/local/pgsql --with-odbc
    G. 安装 man 和 HTML 文件. 类型$ cd /usr/src/pgsql/posgresql-6.5.3/doc$ make install
    H.编译release:$ cd /usr/src/pgsql/src$ make all > make.log 2>&1 &$ tail -f make.log日志最后一行表明: 所有PostgreSQL就绪. 准备安装.
    I. 安装Postgresql:$ gmake install > make.install.log 2>&1 &$ tail -f make.install.log最后一行解释为: 谢谢你使用Postgresql
    J. 告诉你系统怎样找到新的共享的库1. 作为root,编辑文件 /etc/ld.so.conf. 加入一行/usr/local/pgsql/lib2. 运行$ /sbin/ldconfig
    K. 增加路径至.bash_profile为你和 'postgres'用户PATH=$PATH:/usr/local/pgsql/binMANPATH=$MANPATH:/usr/local/pgsql/manPGLIB=/usr/local/pgsql/libPGDATA=/usr/local/pgsql/dataexport PATH MANPATH PGLIB PGDATA
    确信你完整的定义了这些变量:$ source ~/.bash_profile
    3. 快速安装 Postgresql测试A. 以用户 'postgres'创建一个数据库:$ su postgres$ initdb
    B. 设置许可的数据库通道这一步要编辑文件 /usr/local/pgsql/data/pg_hba.conf. 这个文件的默认设置已经足够测试:# By default, allow anything over UNIX domain sockets and localhost.local all trusthost all 127.0.0.1 255.255.255.255 trust
    C. 键入命令在后台运行postmaster daemon$ cd$ nohup postmaster -i > pgserver.log 2>&1 &
    D. 创建一个库$ createdbE. 连接新的数据库$ psqlF. 运行简单的请求postgres SELECT datetime 'now';G. 退出psqlpostgres=> \qH. 增加postgres用户$ su - postgres$ createuser micheleEnter user's postgres ID or RETURN to use unix user ID: 500 ->Is user "tester" allowed to create databases (y/n) yIs user "tester" a superuser? (y/n) ycreateuser: tester was successfully added
    I. 给用户增加一个数据库$ su -$ createdb
    4. 配置ApplixwareA. 编辑 /opt/applix/axdata/axnet.cnf 文件,增加下几行 :libFor gsqlodbc /opt/applix/axdata/axshlib/
    注意: 在applixware 5.0或更高的版本中这个步骤取消
    B. 增加"axnet" 到 /etc/servicesaxnet 5492/tcp # Applix comms process
    C. 在后台启动Applix axnet程序:$ /opt/applix/axdata/axnet &
    D. 接着创建".odbc.ini"文件,在用户home目录下:[ODBC Data Sources]Postgresql=Postgresql database
    [Postgresql]Driver=/usr/local/pgsql/lib/libpsqlodbc.soDatabase=micheleServer=localhostPort=5432ReadOnly=0
    [ODBC]Trace=1TraceFile=/tmp/odbctrace.outInstallDir=/opt/applix/axdata/axshlib
    注意: 在Applixware 5.0 包含一个 postgresql 驱动程序叫做 libodbcpsql.so 在/axdata/axshlib. 如果你想用在axnet.cnf中的ODBCINI变量你就必须要用这个驱动。
    E. 启动 Applix Data 连接Postgresql1. Start Applix Data2. Select Query->Choose Server3. Select the ShelfSQL tab4. Choose the gateway "Shelf ODBC"5. Click on "Specify Connection Info..."6. In the ODBC Connection dialog click on Browse and choose the "Postgresql" selection and click OK; this sets the "Datasource" field7. Click OK in "Choose Server" dbox8. Enter your username for the login and type the password to the database that you created earlier. You should see it successfully connect (It will show a status of "Ready" in the lower left-hand corner of the Data window)
      

  2.   

    谢谢楼上的,我用的是8.1
    而且我的是windows版本...
      

  3.   

    Driver={PostgreSQL};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;