Open wasimwaqia opened 1 year ago
Hello @wasimwaqia ! I'm taking a look.
You can force a specific server when specifying the database, like this: stores@dbservername
.
I'm guessing that irb
is silently connecting to a different dbservername than the adapter you are using. You should see the same error in irb
if you try to connect to stores@muharram
. The question is, which dbserver is irb
connecting to when succeeding?
There are many ways to get the Informix networking setup wrong... Double check /etc/hosts
, $INFORMIXDIR/etc/sqlhosts
as well as the shell environment that irb
and the adapter are using.
Please let me know your findings.
Thank you very much for your reply ,
I want to let you know that both the informix server 14.X developers edition and the sdk are installed in the same server muharram
here is what i found out
Please look at the second part of the screenshot where the @dbservername is omitted the login is successful.
I have attached here a copy of the extract of the informix adapter config in my database.yml, i also noticed that if i change the server: [servername] settings , the configuration doesn't take effect at all I tried with following options a . server: muharram b. server: muharram_tcp c. server: muharram_odbc
The /etc/hosts file
The sqlhosts.dbservername file
and my env variables releated to the informix
Thanking you again.
I see. Let me clarify that the dbservername, if you specify one, should be part of the first argument, the database name, not the user. The correct line should be:
db = new('stores@muharram', 'informix', 'informix')
Which leads me to think that the Rails adapter is doing it wrong or is misconfigured. What Rails adapter is it?
Thank you once again,
I am using both the activerecord and also ruby-infomix adapters
These are the list in the gem file for adding informix connections/adapters
My database.yml file has the following config for the adapter informix
development: <<: *default
adapter: informix server: muharram_tcp # it was muharram first , but trying out various options to get it working. database: stores username: informix password: informix require 'informix' db=Informix.connect('stores', 'informix', 'informix')
I am also following the instructions in the IBM developers hand book](https://www.redbooks.ibm.com/redbooks/pdfs/sg247884.pdf) from page 361 to 396
I am still new to RoR frame work and am trying to learn things.
I guess the server name is being populated from the env variable $INFORMIXSERVER
1st iteration with variable set to muharram
setting the env to muharram
2nd iteration variable set to blank
3rd Iteration the variable set to muharram_odbc
4th iteration setting the variable to some server name example - pronto
Thanks a lot
It looks like there's a mistake in that book. You can see from the source code of the adapter that the server:
setting in the configuration file is not used; only the database, user and password:
def self.informix_connection(config) #:nodoc:
require 'informix' unless self.class.const_defined?(:Informix)
require 'stringio'
config = config.symbolize_keys
database = config[:database].to_s
username = config[:username]
password = config[:password]
db = Informix.connect(database, username, password)
ConnectionAdapters::InformixAdapter.new(db, logger)
end
If you need to specify a server, include it in the database name. In this case it would look like this: stores@muharram_tcp
or stores@muharram
.
Can you give that a try in irb
and Ruby on Rails?
I tried the following 1 update the informix adapter in database.yml file - remove the server: muharram
Output Rails Server - error Error details - Informix::DatabaseError Incorrect password or user informix@muharram is not known on the database server.
irb setting db = new('stores') output success => #<Informix::Database:0x00007f79b41ac220 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
irb setting db = new('stores@muharram') output success => #<Informix::Database:0x00007f79b421c818 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
irb setting db = new('stores@muharram_odbc') output success => #<Informix::Database:0x00007f79b3f47228 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
irb setting db = new('stores@muharram_tcp') output success => #<Informix::Database:0x00007f79b3f58730 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
irb setting db = new('stores@muharram') output success => #<Informix::Database:0x00007f93a8062e60 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
2.b. set the database: stores@muharram_tcp in database.yml file output: error error details Informix::DatabaseError Incorrect password or user informix@localhost[muharram] is not known on the database server.
irb setting db = new('stores@muharram_tcp') output suceess
db = new('stores@muharram_tcp') => #<Informix::Database:0x00007f0f55cd69a8 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
2.c. set the database: stores@muharram_odb in database.yml file output: error error details Informix::DatabaseError Incorrect password or user informix@localhost[muharram] is not known on the database server.
irb setting db = new ('stores@muharram_odbc) output suceess
db = new('stores@muharram_odbc') => #<Informix::Database:0x00007fa2e38bf488 @version=#<struct Struct::IfxVersion server_type="IBM Informix Dynamic Server DE", major="14", minor="10", level="F", os="C5", full="IBM Informix Dynamic Server Version 14.10.FC5DE">>
summary rails adapter within rails server errors with the message Error details - Informix::DatabaseError Incorrect password or user informix@muharram is not known on the database server. . only the hostdetails changes from @muharram to @localhost[muharram] when i add @servername suffix to database: in other words irb works for all the iterations where as the rails adapter does not work.
I am able to run any *.rb files from ruby example i create a ifx_metadata.rb under config directory
require 'informix'
db = Informix.connect(ARGV[0])
print "Connected to #{db.version}\n" db.columns(ARGV[1]).each { |name| name.each {|elem| print " #{elem[0]} #{elem[1]}\n"} } db.close
I can run it with ruby ifx_metadata.rb stores state output is as below
but when i run rails s i get the following error
According to the error message, the adapter is attaching the server name to the username, which is wrong. This adapter however never does that. Are you sure that's the one you're using? You can try finding that file in Rails and edit it to get more debug information.
I have now reinstalled the adapter , however i find something strange when i try to read the adapter settings from irb my adapter settings in the database.yml file is as follows # development:
adapter: informix
database: stores@muharram
username: informix
password: informix
require 'informix'
db = Informix.connect('stores')
when try to query the database.yml configuration in the irb I see some strange output for the variable password the output i get is => "informix require 'informix' db = Informix.connect('stores')" Please see the screenshot below for all my queries for the variables db, dbname, user and password
I tried even separating the lines password and require password: informix
require 'informix'
db = Informix.connect('stores')
when i do this my query for password in irb returns => "informix\nrequire 'informix' db = Informix.connect('stores')"
if i try to alter the adapter settings i get entirely a different error
if i change my database.yml as below
# development:
adapter: informix
database: stores@muharram
username: informix
password: informix
#
require 'informix'
db = Informix.connect('stores')
The error i get goes something like this
Puma caught this error: Cannot load database configuration:
YAML syntax error occurred while parsing /var/www/projects/rails/01storeapp/mystore/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (
screenshot below
from this my conclusion is that the configuration is reading a wrong password and the possible solution would be to isolate the password parameter value and the require parameter
is there a possibility to get the password and the require parameters separated?
Thank you
Indeed, these lines DO NOT belong to the configuration file:
require 'informix'
db = Informix.connect('stores')
Delete them from the configuration file.
If i delete the require 'informix' db = Informix.connect('stores')
I get the error : NotImplementedError NotImplementedError
please let me know In which file should i include this parameters to connect to the db
Thank you Abdul
This code:
require 'informix'
db = Informix.connect('stores')
is not meant to be included in any configuration file. It is definitely not expected if you are using this Ruby on Rails adapter for Informix: https://github.com/santana/activerecord-informix-adapter
I showed above how the configuration file is used, here: https://github.com/santana/activerecord-informix-adapter/blob/9bb3b6dfc59a322a23e1f3e52fb16852c69c3004/lib/active_record/connection_adapters/informix_adapter.rb#L32-L43
No code is expected; only configuration.
Take in account that this adapter https://github.com/santana/activerecord-informix-adapter is old and it's more likely not compatible with newer versions of Ruby on Rails.
Hello, I am trying to build a sample app with the stores demo database, I get the error "Informix::DatabaseError Incorrect password or user informix@[myservername] is not known on the database server."
I am able to connect to the server using irb and query data, however am unable to create any views using the gem 'ruby-informix', '~> 0.8.3' my database.yml config is
adapter: informix
server: my_servername
database: stores username: informix password: informix require 'informix' db=Informix.connect('stores', 'informix', 'informix')
is it possible to force the login with only the username rather than user@servername
I have also checked all my config and I can connect to the server using isql .
Thank you .