• #2 楼 @angelfan 照这种方法也可以解决

  • 终于查清楚原因了,是 dbi 包自身的问题,修改 dbi 的源代码如下: 源代码

    @hash.each_key do |x|
        if x.kind_of? String
            sym = x.to_sym
            if @hash.has_key? sym
                raise ::TypeError, 
                    "#{self.class.name} may construct from a hash keyed with strings or symbols, but not both" 
            end
            @hash[sym] = @hash[x]
            @hash.delete(x)
        end
    end
    

    修改为如下:

    hash_size = @hash.size()
    keys = @hash.keys
    #puts "#{keys}"
    #puts hash_size
    for i in 0..hash_size-1
      keyi = keys[i]
      #puts "#{keyi}"
      if keys[i].kind_of? String
        sym = keyi.to_sym
        if @hash.has_key? sym 
          raise ::TypeError, "#{self.class.name} may construct from a hash keyed with strings or symbols, but not both" 
        end 
        @hash[sym] = @hash[keyi]
        @hash.delete(keyi)
      end 
    end 
    
  • #8 楼 @king1990_cool 错误就是出自 dbh sqlanywhere,现在打算先用 C 连接 sybase,然后在调用 C,试试行不行,谢谢耐心回答

  • #5 楼 @rubyist518 还有什么别的方法能连 sybase ASE/IQ吗?

  • #3 楼 @king1990_cool 不行,提示" Database server not found (DBI::DatabaseError)"错误,还有别的什么方法能连接 sybase 吗?

  • #1 楼 @king1990_cool 用 Mysql 和 Mysql2 都能连接 mysql,现在打算用 sqlanywhere 连接 sybase,问题是用 sqlanywhere,mysql 也连接不了,总出现问题:Database server not found (DBI::DatabaseError)。以下连接语句都不行: dbh=DBI.connect('DBI:SQLAnywhere:db_oa:localhost','root', 'root') dbh=DBI.connect("DBI:SQLAnywhere:Host=192.168.142.128:3306;DatabaseName=db_oa",'root','root') dbh = DBI.connect("DBI:SQLAnywhere:db_oa:localhost","root","root") dbh = DBI.connect("DBI:SQLAnywhere:mydatabase:192.168.100.120","sa","560128") dbh=DBI.connect("DBI:SQLAnywhere:Host=192.168.100.120:5000;DatabaseName=mydatabase",'sa','560128')