php pdo sybase 例子,使用PDO连接到Sybase的正确DSN

我正在尝试使用

PHP的PDO连接到Sybase(SQL Anywhere 12)数据库.我花了好几个小时试图找到正确的驱动程序和DSN使用,没有成功.每次我尝试编辑单个参数时,我总是会遇到错误.我尝试了几十种不同的DSN参数组合,没有任何反应.我在这里只报告一些只是为了举例说明我想要获得的东西.

我成功安装了PDO驱动程序 – 来自php.ini:

PDO drivers dblib, mysql, odbc, pgsql

PDO Driver for FreeTDS/Sybase DB-lib enabled

Flavour freetds

DB参数:

DB的IP为192.168.100.234,db实例和db名称均为GAMMA01.我不能告诉你用户名和密码,但是让我们说:用户dba和pwd好吧.

我可以从尝试启动连接的服务器ping服务器.

我在Linux Debian Squeeze和PHP 5.3.3下.

DBLIB:

我无法找到正确的DSN来连接到我的数据库服务器.

DSN版本1:

'dblib:host=192.168.100.234;DBN=GAMMA01'

DSN第2版:

'dblib:host=192.168.100.234;DBN=GAMMA01;UID=dba;PWD=allright;Server=GAMMA01;ASTART=No'

DSN第3版:

new PDO('dblib:host=192.168.100.234;dbname=GAMMA01', 'dba', 'allright');

我得到的错误

SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)

FreeTDS错误日志(尝试使用版本5.0和7.0,没有区别):

log.c:190:Starting log file for FreeTDS 0.82

on 2014-04-08 13:40:40 with debug flags 0x4fff.

iconv.c:363:iconv to convert client-side data to the "ANSI_X3.4-1968" character set

iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"

iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"

net.c:210:Connecting to 192.168.100.234 port 5200 (TDS version 7.0)

net.c:264:tds_open_socket: connect(2) returned "Operation now in progress"

net.c:299:getsockopt(2) reported: Connection refused

util.c:334:tdserror(0xb9a46eb0, 0xb9b60688, 20009, 115)

dblib.c:7782:dbperror(0xb9b5ff88, 20009, 115)

dblib.c:7835:20009: "Unable to connect: Adaptive Server is unavailable or does not exist"

dblib.c:5627:dbgetuserdata(0xb9b5ff88)

dblib.c:7856:"Unable to connect: Adaptive Server is unavailable or does not exist", client returns 2 (INT_CANCEL)

util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)

util.c:389:tdserror: returning TDS_INT_CANCEL(2)

net.c:310:tds_open_socket() failed

dblib.c:1372:dbclose(0xb9b5ff88)

dblib.c:256:dblib_del_connection(0xb5ceea00, 0xb9b60688)

mem.c:563:tds_free_all_results()

dblib.c:303:dblib_release_tds_ctx(1)

dblib.c:5727:dbfreebuf(0xb9b5ff88)

dblib.c:718:dbloginfree(0xb9b46588)

使用sybase:DSN:

'sybase:host=192.168.100.234;dbname=GAMMA01, dba, allright'

错误:

could not find driver

DSN:

'odbc:Driver={Sybase SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'

'odbc:Driver={SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'

'odbc:DRIVER={Sybase SQL Anywhere 12};SRVR=192.168.100.234;DB=gamma01;UID=dba;PWD=allright;'

'odbc:DRIVER={Sybase SQL Anywhere 12};HOSTNAME=192.168.100.234;DATABASE=gamma01;UID=dba;PWD=allright;PROTOCOL:TCPIP'

我得到的错误:

SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified

我应该使用哪个驱动程序连接到Sybase db?哪个是正确的DSN?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值