Class: DbMeta::Oracle::Connection
- Inherits:
-
Object
- Object
- DbMeta::Oracle::Connection
- Includes:
- Singleton
- Defined in:
- lib/db_meta/oracle/connection.rb
Instance Attribute Summary collapse
-
#database_instance ⇒ Object
Returns the value of attribute database_instance.
-
#password ⇒ Object
Returns the value of attribute password.
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
-
#username ⇒ Object
Returns the value of attribute username.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
Instance Attribute Details
#database_instance ⇒ Object
Returns the value of attribute database_instance.
8 9 10 |
# File 'lib/db_meta/oracle/connection.rb', line 8 def database_instance @database_instance end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/db_meta/oracle/connection.rb', line 8 def password @password end |
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
9 10 11 |
# File 'lib/db_meta/oracle/connection.rb', line 9 def pool @pool end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/db_meta/oracle/connection.rb', line 8 def username @username end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
10 11 12 |
# File 'lib/db_meta/oracle/connection.rb', line 10 def worker @worker end |
Instance Method Details
#disconnect ⇒ Object
30 31 32 33 34 35 |
# File 'lib/db_meta/oracle/connection.rb', line 30 def disconnect return unless @pool @pool.destroy Log.info("Logged off from #{@username}@#{@database_instance}") @pool = nil end |
#get ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/db_meta/oracle/connection.rb', line 19 def get unless @pool # create connection pool @pool = ::OCI8::ConnectionPool.new(1, @worker, 1, @username, @password, @database_instance) Log.info("Connected to #{@username}@#{@database_instance}") end # create and return logical connection. It creates physical connection as needed. ::OCI8.new(@username, @password, @pool) end |
#set(username, password, database_instance, worker) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/db_meta/oracle/connection.rb', line 12 def set(username, password, database_instance, worker) @username = username @password = password @database_instance = database_instance @worker = worker end |