2014-05-06 160 views
1

我寫這篇PostgreSQL的代碼行,但我有以下錯誤:postgres_fdw錯誤無法連接服務器

ERROR: could not connect to server "server\sqlexpress"

SQL state: 08001

我在做什麼錯?

我的代碼:

在Windows 8.1和MS SQL快遞2012使用PostgreSQL 9.3相同的Windows

CREATE EXTENSION posgres_fdw; 
    Query returned successfully with no result in 11 ms. 

    CREATE SERVER "server\SQLExpress" FOREIGN DATA WRAPPER postgres_fdw 
    OPTIONS (host 'localhost', dbname 'andesmar'); 
    Query returned successfully with no result in 12 ms. 

    CREATE USER MAPPING FOR public SERVER "server\sqlexpress" 
    OPTIONS (user 'sa', password '1234'); 
    Query returned successfully with no result in 12 ms. 

    CREATE FOREIGN TABLE datosplataforma (
    id     bigint NOT NULL, 
    messagedate  date NOT NULL, 
    receiveddate  date NOT NULL, 
    latitude   real, 
    longitude   real, 
    GPSspeed   real, 
    bearingangle  integer, 
    odometer   integer, 
    eventtypeid  integer, 
    vehicleid   integer, 
    alertid   integer 
    ) 
    SERVER "server\sqlexpress"; 
    Query returned successfully with no result in 12 ms. 

    select * from datosplataforma; 
    ERROR: could not connect to server "server\sqlexpress" 
    SQL state: 08001 

回答

4

postgres_fdw連接到另一臺PostgreSQL服務器,而不是MS SQL服務器。

如果要連接到MS SQL,則需要將ODBC或JDBC FDW與MS SQL ODBC或JDBC驅動程序一起使用,或使用專用的MS SQL FDW。

參見:http://wiki.postgresql.org/wiki/Foreign_data_wrappers

相關問題