class OCI8::ConnectionPool


# The number of logical connections: 0
# The number of physical connections: 3
# All logical connections were closed.
conn2.logoff
# The number of logical connections: 1
# The number of physical connections: 3
# One logical connection was closed.
conn1.logoff
# The number of logical connections: 2
# The number of physical connections: 3
# So that the number of physical connections is incremented.
# Logical connections cannot use one physical connection at a time.
thr2.join
thr1.join
end
conn2.exec(‘…’)
thr2 = Thread.new do
end
conn1.exec(‘…’)
thr1 = Thread.new do
# The number of logical connections: 2
# The number of physical connections: 1
# Both logical connections use one physical connection.
conn2.exec(‘…’)
conn1.exec(‘…’)
# Use conn1 and conn2 sequentially
# The number of logical connections: 2
# The number of physical connections: 1
# Another logical connection was created.
conn2 = OCI8.new(username, password, cpool)
# Create another session.
# The number of logical connections: 1
# The number of physical connections: 1
# One logical connection was created.
conn1 = OCI8.new(username, password, cpool)
# Pass the connection pool to the third argument.
# Create a session.
# The number of logical connections: 0
# The number of physical connections: 1
cpool = OCI8::ConnectionPool.new(1, 5, 2, username, password, database)
# username and password are required to establish an implicit primary session.
# the connection increment parameter: 2
# The number of maximum physical connections: 5
# The number of initial physical connections: 1
# Create a connection pool.
Example:
query at a time.
because one physical connection cannot transmit more then one
queries at a time, it needs more than one physical connection
physical connection is used. When an application sends
As long as logical connections are used sequentially, only one
returns to the pool automatically when the query finishes.
physical connection is got from the pool. The physical connection
When an application sends a query via a logical connection, a
establish a connection unlike generally called connection pooling.
is created via a physical connection, which needs time to
When an application needs a new connection, a logical connection
caches physical connections in a pool, not logical connections.
is used by an application. The connection pooling in ruby-oci8
connection such as TCP/IP. The other is logical connection which
One Oracle connection is devided into two layers: One is physical
above.
reduced. However connection pooling in ruby-oci8 is different with
the pool. So that the amount of time to establish a connection is
When an application needs a new connection, a connection is got from
Generally connection pooling caches connections in a pool.
Note that this is different with generally called connection pooling.
This is equivalent to Oracle JDBC Driver OCI Connection Pooling.
See: {Oracle Call Interface Manual}[http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci09adv.htm#sthref1479]
physical connections by several sessions to balance loads.
Connection pooling is the use of a group (the pool) of reusable

def busy_count

Returns:
  • (Integer) -
def busy_count
  attr_get_ub4(OCI_ATTR_CONN_BUSY_COUNT)
end

def destroy

def destroy
  free
end

def incr

Returns:
  • (Integer) -
def incr
  attr_get_ub4(OCI_ATTR_CONN_INCR)
end

def max

Returns:
  • (Integer) -
def max
  attr_get_ub4(OCI_ATTR_CONN_MAX)
end

def min

Returns:
  • (Integer) -
def min
  attr_get_ub4(OCI_ATTR_CONN_MIN)
end

def nowait=(val)

Parameters:
  • val (Boolean) --
def nowait=(val)
  attr_set_ub1(OCI_ATTR_CONN_NOWAIT, val ? 1 : 0)
end

def nowait?

The default value is false.
maximum. Otherwise the call waits till it gets a connection.
are busy and the number of connections has already reached the
If true, an error is thrown when all the connections in the pool
def nowait?
  attr_get_ub1(OCI_ATTR_CONN_NOWAIT) != 0
end

def open_count

Returns:
  • (Integer) -
def open_count
  attr_get_ub4(OCI_ATTR_CONN_OPEN_COUNT)
end

def timeout

Returns:
  • (Integer) -
def timeout
  attr_get_ub4(OCI_ATTR_CONN_TIMEOUT)
end

def timeout=(val)

Parameters:
  • val (Integer) --
def timeout=(val)
  attr_set_ub4(OCI_ATTR_CONN_TIMEOUT, val)
end