Class: OCI8::ConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/oci8/connection_pool.rb

Overview

Connection pooling is the use of a group (the pool) of reusable physical connections by several sessions to balance loads. See: Oracle Call Interface Manual

This is equivalent to Oracle JDBC Driver OCI Connection Pooling.

Usage:

# Create a connection pool.
# username and password are required to establish an implicit primary session.
cpool = OCI8::ConnectionPool.new(1, 5, 2, username, password, database)

# Get a session from the pool.
# Pass the connection pool to the third argument.
conn1 = OCI8.new(username, password, cpool)

# Get another session.
conn2 = OCI8.new(username, password, cpool)

Instance Method Summary collapse

Instance Method Details

#busy_countInteger

Returns the number of busy physical connections.

Returns:

  • (Integer)


71
72
73
# File 'lib/oci8/connection_pool.rb', line 71

def busy_count
  attr_get_ub4(OCI_ATTR_CONN_BUSY_COUNT)
end

#destroyObject



104
105
106
# File 'lib/oci8/connection_pool.rb', line 104

def destroy
  free
end

#incrInteger

Returns the connection increment parameter.

Returns:

  • (Integer)


99
100
101
# File 'lib/oci8/connection_pool.rb', line 99

def incr
  attr_get_ub4(OCI_ATTR_CONN_INCR)
end

#maxInteger

Returns the number of maximum physical connections.

Returns:

  • (Integer)


92
93
94
# File 'lib/oci8/connection_pool.rb', line 92

def max
  attr_get_ub4(OCI_ATTR_CONN_MAX)
end

#minInteger

Returns the number of minimum physical connections.

Returns:

  • (Integer)


85
86
87
# File 'lib/oci8/connection_pool.rb', line 85

def min
  attr_get_ub4(OCI_ATTR_CONN_MIN)
end

#nowait=(val) ⇒ Object

Changes the behavior when all the connections in the pool are busy and the number of connections has already reached the maximum.

Parameters:

  • val (Boolean)


64
65
66
# File 'lib/oci8/connection_pool.rb', line 64

def nowait=(val)
  attr_set_ub1(OCI_ATTR_CONN_NOWAIT, val ? 1 : 0)
end

#nowait?Boolean

If true, an error is thrown when all the connections in the pool are busy and the number of connections has already reached the maximum. Otherwise the call waits till it gets a connection. The default value is false.

Returns:

  • (Boolean)


55
56
57
# File 'lib/oci8/connection_pool.rb', line 55

def nowait?
  attr_get_ub1(OCI_ATTR_CONN_NOWAIT) != 0
end

#open_countInteger

Returns the number of open physical connections.

Returns:

  • (Integer)


78
79
80
# File 'lib/oci8/connection_pool.rb', line 78

def open_count
  attr_get_ub4(OCI_ATTR_CONN_OPEN_COUNT)
end

#timeoutInteger

Connections idle for more than this time value (in seconds) are terminated, to maintain an optimum number of open connections. If it is zero, the connections are never timed out. The default value is zero.

Note: Shrinkage of the pool only occurs when there is a network round trip. If there are no operations, then the connections stay alive.

Returns:

  • (Integer)


40
41
42
# File 'lib/oci8/connection_pool.rb', line 40

def timeout
  attr_get_ub4(OCI_ATTR_CONN_TIMEOUT)
end

#timeout=(val) ⇒ Object

Changes the timeout in seconds to terminate idle connections.

Parameters:

  • val (Integer)


47
48
49
# File 'lib/oci8/connection_pool.rb', line 47

def timeout=(val)
  attr_set_ub4(OCI_ATTR_CONN_TIMEOUT, val)
end