zoukankan      html  css  js  c++  java
  • 在Linux平台创建PostgreSQL ODBC的文件DSN的简易方法

    某C程序在操作数据库时,是以文件dsn形式来读取ODBC数据源。当该程序移植到Linux平台和PostgreSQL数据库时遇到一点麻烦,即如何简单易行地创建文件dsn?

    遗憾的是,在网上几乎搜索不到Linux + PostgreSQL + 文件dsn的方法。

    通过多次实践,终于找到一种简单的方式:

    1. 在Linux上安装unixODBC;
    2. 在Linux安装psqlODBC;
    3. 配置/etc/odbcinst.ini和/etc/odbc.ini文件;
    4. 手工生成文件dsn文件。

    其中前三个步骤是必须的,也很容易在网上搜索到,不再赘述。

    对于最后一步,将Windows上的一个PostgreSql的文件dsn拷贝过来,再修改Driver项即可。比如:

    [ODBC]
    DRIVER=/usr/local/lib/libpsqlodbc-x.x.x.so
    UID=pg_file_dsn
    XaOpt=3
    GssAuthUseGSS=0
    LowerCaseIdentifier=0
    UseServerSidePrepare=1
    ByteaAsLongVarBinary=0
    BI=0
    TrueIsMinus1=0
    UpdatableCursors=1
    LFConversion=1
    ExtraSysTablePrefixes=dd_
    Parse=0
    BoolsAsChar=1
    UnknownsAsLongVarchar=0
    TextAsLongVarchar=1
    UseDeclareFetch=0
    CommLog=0
    Debug=0
    MaxLongVarcharSize=8190
    MaxVarcharSize=255
    UnknownSizes=0
    Fetch=100
    ConnSettings=
    ShowSystemTables=0
    RowVersioning=0
    ShowOidColumn=0
    FakeOidIndex=0
    Protocol=7.4-1
    ReadOnly=0
    SSLmode=disable
    PORT=5432
    SERVER=10.100.1.100
    DATABASE=mydb
  • 相关阅读:
    java web 资源文件读取
    页面跳转
    验证码的随机图片
    spring 注解
    回文字符串系列问题
    【leetcode】Find All Anagrams in a String
    斐波那契数列
    【leetcode】 First Missing Positive
    Trapping Rain Water
    区间合并问题
  • 原文地址:https://www.cnblogs.com/wggj/p/10297658.html
Copyright © 2011-2022 走看看