jdbc-helper 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -4
- data/lib/jdbc-helper/connection/prepared_statement.rb +5 -0
- data/lib/jdbc-helper/connection.rb +6 -1
- data/test/test_connection.rb +26 -0
- metadata +3 -5
data/README.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
_ _ _ _ _
|
2
|
+
(_) | | | | | | |
|
3
|
+
_ __| | |__ ___ ______| |__ ___| |_ __ ___ _ __
|
4
|
+
| |/ _` | '_ \ / __|______| '_ \ / _ \ | '_ \ / _ \ '__|
|
5
|
+
| | (_| | |_) | (__ | | | | __/ | |_) | __/ |
|
6
|
+
| |\__,_|_.__/ \___| |_| |_|\___|_| .__/ \___|_|
|
7
|
+
_/ | | |
|
8
|
+
|__/ |_|
|
9
|
+
|
1
10
|
= jdbc-helper
|
2
11
|
|
3
12
|
A JDBC helper for Ruby/Database developers.
|
@@ -181,14 +190,14 @@ Add the appropriate JDBC drivers to the CLASSPATH.
|
|
181
190
|
# Working with IN/INOUT/OUT parameteres
|
182
191
|
# Bind by ordinal number
|
183
192
|
conn.procedure(:update_and_fetch_something).call(
|
184
|
-
|
185
|
-
|
186
|
-
|
193
|
+
100, # Input parameter
|
194
|
+
["value", String], # Input/Output parameter
|
195
|
+
Fixnum # Output parameter
|
187
196
|
)
|
188
197
|
|
189
198
|
# Bind by parameter name
|
190
199
|
conn.procedure(:update_and_fetch_something).call(
|
191
|
-
|
200
|
+
:a => 100, :b => ["value", String], :c => Fixnum)
|
192
201
|
|
193
202
|
=== Using sequence wrappers (since 0.4.2)
|
194
203
|
seq = conn.sequence(:my_seq)
|
@@ -77,9 +77,14 @@ class PreparedStatement < ParameterizedStatement
|
|
77
77
|
def set_fetch_size(fsz)
|
78
78
|
check_closed
|
79
79
|
|
80
|
+
@fetch_size = fsz
|
80
81
|
@java_obj.set_fetch_size fsz
|
81
82
|
end
|
83
|
+
alias fetch_size= set_fetch_size
|
82
84
|
|
85
|
+
# Returns the fetch size of the prepared statement. If not set, nil is returned.
|
86
|
+
# @return [Fixnum]
|
87
|
+
attr_reader :fetch_size
|
83
88
|
private
|
84
89
|
def set_params(params) # :nodoc:
|
85
90
|
params.each_with_index do | param, idx |
|
@@ -169,7 +169,7 @@ class Connection
|
|
169
169
|
|
170
170
|
props = java.util.Properties.new
|
171
171
|
(args.keys - [:url, :driver]).each do | key |
|
172
|
-
props.setProperty(key.to_s, args[key]) if args[key]
|
172
|
+
props.setProperty(key.to_s, args[key].to_s) if args[key]
|
173
173
|
end
|
174
174
|
|
175
175
|
@conn = JavaSql::DriverManager.get_connection(@url, props)
|
@@ -344,6 +344,11 @@ class Connection
|
|
344
344
|
@fetch_size = fsz
|
345
345
|
@spool.each { | stmt | stmt.set_fetch_size @fetch_size }
|
346
346
|
end
|
347
|
+
alias fetch_size= set_fetch_size
|
348
|
+
|
349
|
+
# Returns the fetch size of the connection. If not set, nil is returned.
|
350
|
+
# @return [Fixnum]
|
351
|
+
attr_reader :fetch_size
|
347
352
|
|
348
353
|
# Closes the connection
|
349
354
|
# @return [NilClass]
|
data/test/test_connection.rb
CHANGED
@@ -81,6 +81,9 @@ class TestConnection < Test::Unit::TestCase
|
|
81
81
|
conn_info[str_key.to_sym] = conn_info.delete str_key
|
82
82
|
end if i % 2 == 0
|
83
83
|
|
84
|
+
# Integers will be converted to String
|
85
|
+
#conn_info['defaultRowPrefetch'] = 1000
|
86
|
+
|
84
87
|
conn = JDBCHelper::Connection.new(conn_info)
|
85
88
|
assert_equal(conn.closed?, false)
|
86
89
|
assert_equal(conn.driver, conn_info[:driver] || conn_info['driver'])
|
@@ -105,6 +108,18 @@ class TestConnection < Test::Unit::TestCase
|
|
105
108
|
end
|
106
109
|
end
|
107
110
|
|
111
|
+
def test_fetch_size
|
112
|
+
each_connection do | conn |
|
113
|
+
assert_nil conn.fetch_size
|
114
|
+
conn.fetch_size = 10
|
115
|
+
assert_equal 10, conn.fetch_size
|
116
|
+
conn.set_fetch_size 20
|
117
|
+
assert_equal 20, conn.fetch_size
|
118
|
+
|
119
|
+
# No way to confirm whether if this is really working as it's supposed to be.
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
108
123
|
def test_query_enumerate
|
109
124
|
each_connection do | conn |
|
110
125
|
# Query without a block => Array
|
@@ -170,6 +185,17 @@ class TestConnection < Test::Unit::TestCase
|
|
170
185
|
sel = conn.prepare get_one_two
|
171
186
|
assert sel.closed? == false
|
172
187
|
|
188
|
+
# Fetch size
|
189
|
+
assert_nil conn.fetch_size
|
190
|
+
assert_nil sel.fetch_size
|
191
|
+
conn.fetch_size = 100
|
192
|
+
sel.fetch_size = 10
|
193
|
+
assert_equal 100, conn.fetch_size
|
194
|
+
assert_equal 10, sel.fetch_size
|
195
|
+
sel.set_fetch_size 20
|
196
|
+
assert_equal 100, conn.fetch_size
|
197
|
+
assert_equal 20, sel.fetch_size
|
198
|
+
|
173
199
|
# Query without a block => Array
|
174
200
|
query_result = sel.query
|
175
201
|
assert query_result.is_a? Array
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jdbc-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Junegunn Choi
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-07-12 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: bundler
|
@@ -96,7 +95,6 @@ files:
|
|
96
95
|
- test/test_object_wrapper.rb
|
97
96
|
- test/test_performance.rb
|
98
97
|
- test/test_sql.rb
|
99
|
-
has_rdoc: true
|
100
98
|
homepage: http://github.com/junegunn/jdbc-helper
|
101
99
|
licenses:
|
102
100
|
- MIT
|
@@ -123,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
121
|
requirements: []
|
124
122
|
|
125
123
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.5
|
124
|
+
rubygems_version: 1.8.5
|
127
125
|
signing_key:
|
128
126
|
specification_version: 3
|
129
127
|
summary: A JDBC helper for JRuby/Database developers.
|