ruby-oci8 2.2.10-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +14 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +3826 -0
- data/Makefile +92 -0
- data/NEWS +1209 -0
- data/README.md +66 -0
- data/dist-files +112 -0
- data/docs/bind-array-to-in_cond.md +38 -0
- data/docs/conflicts-local-connections-and-processes.md +98 -0
- data/docs/hanging-after-inactivity.md +63 -0
- data/docs/install-binary-package.md +44 -0
- data/docs/install-full-client.md +111 -0
- data/docs/install-instant-client.md +194 -0
- data/docs/install-on-osx.md +46 -0
- data/docs/ldap-auth-and-function-interposition.md +123 -0
- data/docs/number-type-mapping.md +79 -0
- data/docs/platform-specific-issues.md +164 -0
- data/docs/report-installation-issue.md +50 -0
- data/docs/timeout-parameters.md +94 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +333 -0
- data/lib/oci8/check_load_error.rb +146 -0
- data/lib/oci8/compat.rb +117 -0
- data/lib/oci8/connection_pool.rb +179 -0
- data/lib/oci8/cursor.rb +605 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +45 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2148 -0
- data/lib/oci8/object.rb +641 -0
- data/lib/oci8/oci8.rb +756 -0
- data/lib/oci8/ocihandle.rb +591 -0
- data/lib/oci8/oracle_version.rb +153 -0
- data/lib/oci8/properties.rb +196 -0
- data/lib/oci8/version.rb +3 -0
- data/lib/oci8.rb +190 -0
- data/lib/oci8lib_310.so +0 -0
- data/lib/ruby-oci8.rb +1 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +85 -0
- data/setup.rb +1342 -0
- data/test/README.md +37 -0
- data/test/config.rb +201 -0
- data/test/setup_test_object.sql +199 -0
- data/test/setup_test_package.sql +59 -0
- data/test/test_all.rb +56 -0
- data/test/test_appinfo.rb +62 -0
- data/test/test_array_dml.rb +332 -0
- data/test/test_bind_array.rb +70 -0
- data/test/test_bind_boolean.rb +99 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_bind_raw.rb +45 -0
- data/test/test_bind_string.rb +105 -0
- data/test/test_bind_time.rb +177 -0
- data/test/test_break.rb +125 -0
- data/test/test_clob.rb +85 -0
- data/test/test_connection_pool.rb +124 -0
- data/test/test_connstr.rb +220 -0
- data/test/test_datetime.rb +585 -0
- data/test/test_dbi.rb +365 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +103 -0
- data/test/test_error.rb +87 -0
- data/test/test_metadata.rb +2674 -0
- data/test/test_object.rb +546 -0
- data/test/test_oci8.rb +624 -0
- data/test/test_oracle_version.rb +68 -0
- data/test/test_oradate.rb +255 -0
- data/test/test_oranumber.rb +792 -0
- data/test/test_package_type.rb +981 -0
- data/test/test_properties.rb +17 -0
- data/test/test_rowid.rb +32 -0
- metadata +123 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
#--
|
2
|
+
# connection_pool.rb -- OCI8::ConnectionPool
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 KUBO Takehiro <kubo@jiubao.org>
|
5
|
+
#++
|
6
|
+
|
7
|
+
#
|
8
|
+
class OCI8
|
9
|
+
|
10
|
+
# Connection pooling is the use of a group (the pool) of reusable
|
11
|
+
# physical connections by several sessions to balance loads.
|
12
|
+
# See: {Oracle Call Interface Manual}[http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci09adv.htm#sthref1479]
|
13
|
+
#
|
14
|
+
# This is equivalent to Oracle JDBC Driver {OCI Connection Pooling}[http://docs.oracle.com/cd/E11882_01/java.112/e16548/ociconpl.htm#JJDBC28789].
|
15
|
+
#
|
16
|
+
# Note that this is different with generally called connection pooling.
|
17
|
+
# Generally connection pooling caches connections in a pool.
|
18
|
+
# When an application needs a new connection, a connection is got from
|
19
|
+
# the pool. So that the amount of time to establish a connection is
|
20
|
+
# reduced. However connection pooling in ruby-oci8 is different with
|
21
|
+
# above.
|
22
|
+
#
|
23
|
+
# One Oracle connection is devided into two layers: One is physical
|
24
|
+
# connection such as TCP/IP. The other is logical connection which
|
25
|
+
# is used by an application. The connection pooling in ruby-oci8
|
26
|
+
# caches physical connections in a pool, not logical connections.
|
27
|
+
# When an application needs a new connection, a logical connection
|
28
|
+
# is created via a physical connection, which needs time to
|
29
|
+
# establish a connection unlike generally called connection pooling.
|
30
|
+
# When an application sends a query via a logical connection, a
|
31
|
+
# physical connection is got from the pool. The physical connection
|
32
|
+
# returns to the pool automatically when the query finishes.
|
33
|
+
# As long as logical connections are used sequentially, only one
|
34
|
+
# physical connection is used. When an application sends
|
35
|
+
# queries at a time, it needs more than one physical connection
|
36
|
+
# because one physical connection cannot transmit more then one
|
37
|
+
# query at a time.
|
38
|
+
#
|
39
|
+
# Example:
|
40
|
+
# # Create a connection pool.
|
41
|
+
# # The number of initial physical connections: 1
|
42
|
+
# # The number of maximum physical connections: 5
|
43
|
+
# # the connection increment parameter: 2
|
44
|
+
# # username and password are required to establish an implicit primary session.
|
45
|
+
# cpool = OCI8::ConnectionPool.new(1, 5, 2, username, password, database)
|
46
|
+
#
|
47
|
+
# # The number of physical connections: 1
|
48
|
+
# # The number of logical connections: 0
|
49
|
+
#
|
50
|
+
# # Create a session.
|
51
|
+
# # Pass the connection pool to the third argument.
|
52
|
+
# conn1 = OCI8.new(username, password, cpool)
|
53
|
+
#
|
54
|
+
# # One logical connection was created.
|
55
|
+
# # The number of physical connections: 1
|
56
|
+
# # The number of logical connections: 1
|
57
|
+
#
|
58
|
+
# # Create another session.
|
59
|
+
# conn2 = OCI8.new(username, password, cpool)
|
60
|
+
#
|
61
|
+
# # Another logical connection was created.
|
62
|
+
# # The number of physical connections: 1
|
63
|
+
# # The number of logical connections: 2
|
64
|
+
#
|
65
|
+
# # Use conn1 and conn2 sequentially
|
66
|
+
# conn1.exec('...')
|
67
|
+
# conn2.exec('...')
|
68
|
+
#
|
69
|
+
# # Both logical connections use one physical connection.
|
70
|
+
# # The number of physical connections: 1
|
71
|
+
# # The number of logical connections: 2
|
72
|
+
#
|
73
|
+
# thr1 = Thread.new do
|
74
|
+
# conn1.exec('...')
|
75
|
+
# end
|
76
|
+
# thr2 = Thread.new do
|
77
|
+
# conn2.exec('...')
|
78
|
+
# end
|
79
|
+
# thr1.join
|
80
|
+
# thr2.join
|
81
|
+
#
|
82
|
+
# # Logical connections cannot use one physical connection at a time.
|
83
|
+
# # So that the number of physical connections is incremented.
|
84
|
+
# # The number of physical connections: 3
|
85
|
+
# # The number of logical connections: 2
|
86
|
+
#
|
87
|
+
# conn1.logoff
|
88
|
+
#
|
89
|
+
# # One logical connection was closed.
|
90
|
+
# # The number of physical connections: 3
|
91
|
+
# # The number of logical connections: 1
|
92
|
+
#
|
93
|
+
# conn2.logoff
|
94
|
+
#
|
95
|
+
# # All logical connections were closed.
|
96
|
+
# # The number of physical connections: 3
|
97
|
+
# # The number of logical connections: 0
|
98
|
+
#
|
99
|
+
class ConnectionPool
|
100
|
+
|
101
|
+
# Connections idle for more than this time value (in seconds) are
|
102
|
+
# terminated, to maintain an optimum number of open
|
103
|
+
# connections. If it is zero, the connections are never timed out.
|
104
|
+
# The default value is zero.
|
105
|
+
#
|
106
|
+
# <b>Note:</b> Shrinkage of the pool only occurs when there is a network
|
107
|
+
# round trip. If there are no operations, then the connections
|
108
|
+
# stay alive.
|
109
|
+
#
|
110
|
+
# @return [Integer]
|
111
|
+
def timeout
|
112
|
+
attr_get_ub4(OCI_ATTR_CONN_TIMEOUT)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Changes the timeout in seconds to terminate idle connections.
|
116
|
+
#
|
117
|
+
# @param [Integer] val
|
118
|
+
def timeout=(val)
|
119
|
+
attr_set_ub4(OCI_ATTR_CONN_TIMEOUT, val)
|
120
|
+
end
|
121
|
+
|
122
|
+
# If true, an error is thrown when all the connections in the pool
|
123
|
+
# are busy and the number of connections has already reached the
|
124
|
+
# maximum. Otherwise the call waits till it gets a connection.
|
125
|
+
# The default value is false.
|
126
|
+
def nowait?
|
127
|
+
attr_get_ub1(OCI_ATTR_CONN_NOWAIT) != 0
|
128
|
+
end
|
129
|
+
|
130
|
+
# Changes the behavior when all the connections in the pool
|
131
|
+
# are busy and the number of connections has already reached the
|
132
|
+
# maximum.
|
133
|
+
#
|
134
|
+
# @param [Boolean] val
|
135
|
+
def nowait=(val)
|
136
|
+
attr_set_ub1(OCI_ATTR_CONN_NOWAIT, val ? 1 : 0)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns the number of busy physical connections.
|
140
|
+
#
|
141
|
+
# @return [Integer]
|
142
|
+
def busy_count
|
143
|
+
attr_get_ub4(OCI_ATTR_CONN_BUSY_COUNT)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns the number of open physical connections.
|
147
|
+
#
|
148
|
+
# @return [Integer]
|
149
|
+
def open_count
|
150
|
+
attr_get_ub4(OCI_ATTR_CONN_OPEN_COUNT)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Returns the number of minimum physical connections.
|
154
|
+
#
|
155
|
+
# @return [Integer]
|
156
|
+
def min
|
157
|
+
attr_get_ub4(OCI_ATTR_CONN_MIN)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the number of maximum physical connections.
|
161
|
+
#
|
162
|
+
# @return [Integer]
|
163
|
+
def max
|
164
|
+
attr_get_ub4(OCI_ATTR_CONN_MAX)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the connection increment parameter.
|
168
|
+
#
|
169
|
+
# @return [Integer]
|
170
|
+
def incr
|
171
|
+
attr_get_ub4(OCI_ATTR_CONN_INCR)
|
172
|
+
end
|
173
|
+
|
174
|
+
#
|
175
|
+
def destroy
|
176
|
+
free
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|