georgiev / rubyfb

ruby/rails Firebird db access library
Other
16 stars 5 forks source link

Error opening database connection #6

Closed tuxjobs closed 12 years ago

tuxjobs commented 12 years ago

`connect': Error opening database connection. (Rubyfb::FireRubyException) unable to allocate memory from operating system Unsuccessful execution caused by an unavailable resource. SQL Code = -904

The first 77 connections are ok...

....each{|sql| db = Database.new(...) cxn = db.connect(...) cxn.execute_immediate(sql).each{|v| puts v[:field] } }

Is there something wrong with my code?l

georgiev commented 12 years ago

This error has nothing to do with the rubyfb, this is firebird client error and I'm not surprised - you are opening a new connection for each SQL statement (as far as I can tell from the code snippet) and leaving it open. You should either close the connection after using it or MUCH better - use one connection for all statements and then close it like that: db = Database.new(...) cxn = db.connect(...) ....each{|sql| cxn.execute_immediate(sql).each{|v| puts v[:field] } } cxn.close

tuxjobs commented 12 years ago

ok, i'm sorry - i thought that after each block, the connection object would be destroyed, and there for the connection closed. My mistake.

georgiev commented 12 years ago

Rubyfb objects connection,statement and result set require explicit close