jdbc-helper 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/CHANGELOG.markdown +158 -0
- data/Gemfile +4 -0
- data/README.markdown +34 -6
- data/Rakefile +24 -0
- data/VERSION +1 -0
- data/jdbc-helper.gemspec +22 -0
- data/lib/jdbc-helper/connection.rb +3 -3
- data/lib/jdbc-helper/connector/cassandra.rb +21 -0
- data/lib/jdbc-helper/connector/mssql.rb +40 -0
- data/lib/jdbc-helper/connector/mysql.rb +36 -0
- data/lib/jdbc-helper/connector/oracle.rb +58 -0
- data/lib/jdbc-helper/connector/postgresql.rb +40 -0
- data/lib/jdbc-helper/connector.rb +27 -13
- data/lib/jdbc-helper/constants.rb +19 -15
- data/lib/jdbc-helper/version.rb +3 -0
- data/lib/jdbc-helper.rb +2 -0
- data/test/helper.rb +6 -4
- data/test/test_connection.rb +10 -8
- data/test/test_connectors.rb +97 -1
- metadata +132 -161
- data/lib/jdbc-helper/connector/mysql_connector.rb +0 -37
- data/lib/jdbc-helper/connector/oracle_connector.rb +0 -46
- data/lib/jdbc-helper/connector/postgres_connector.rb +0 -37
- data/lib/jdbc-helper/connector/sql_server_connector.rb +0 -37
- data/test/database.yml.local +0 -31
data/test/test_connection.rb
CHANGED
@@ -74,7 +74,7 @@ class TestConnection < Test::Unit::TestCase
|
|
74
74
|
|
75
75
|
def test_inspect
|
76
76
|
config.each do | db, conn_info_org |
|
77
|
-
conn_info = conn_info_org.reject { |k,v| k == 'database' }
|
77
|
+
conn_info = conn_info_org.reject { |k,v| k == 'database' }.insensitive
|
78
78
|
conn = JDBCHelper::Connection.new(conn_info)
|
79
79
|
insp = InsensitiveHash[ eval( conn.inspect.gsub('=>', ' => ') ) ]
|
80
80
|
|
@@ -91,10 +91,10 @@ class TestConnection < Test::Unit::TestCase
|
|
91
91
|
def test_connect_clone_and_close
|
92
92
|
config.each do | db, conn_info_org |
|
93
93
|
4.times do | i |
|
94
|
-
conn_info = conn_info_org.reject { |k,v| k == 'database' }
|
94
|
+
conn_info = conn_info_org.reject { |k,v| k == 'database' }.insensitive
|
95
95
|
|
96
96
|
# With or without timeout parameter
|
97
|
-
conn_info[
|
97
|
+
conn_info[:timeout] = 60 if i % 2 == 1
|
98
98
|
|
99
99
|
# Can connect with hash with symbol keys?
|
100
100
|
conn_info.keys.each do | str_key |
|
@@ -107,8 +107,8 @@ class TestConnection < Test::Unit::TestCase
|
|
107
107
|
conn_info.freeze # Non-modifiable!
|
108
108
|
conn = JDBCHelper::Connection.new(conn_info)
|
109
109
|
assert_equal(conn.closed?, false)
|
110
|
-
assert_equal(conn.driver, conn_info[:driver]
|
111
|
-
assert_equal(conn.url, conn_info[:url]
|
110
|
+
assert_equal(conn.driver, conn_info[:driver])
|
111
|
+
assert_equal(conn.url, conn_info[:url])
|
112
112
|
|
113
113
|
conn.fetch_size = 100
|
114
114
|
assert_equal 100, conn.fetch_size
|
@@ -135,9 +135,11 @@ class TestConnection < Test::Unit::TestCase
|
|
135
135
|
c2 = c.clone
|
136
136
|
assert c2.java_obj != c.java_obj
|
137
137
|
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
unless conn_info[:driver] =~ /cassandra/
|
139
|
+
c.query('select 1 from dual')
|
140
|
+
c2.query('select 1 from dual')
|
141
|
+
drop_dual! c
|
142
|
+
end
|
141
143
|
|
142
144
|
assert_equal c.closed?, false
|
143
145
|
|
data/test/test_connectors.rb
CHANGED
@@ -9,8 +9,104 @@ class TestConnectors < Test::Unit::TestCase
|
|
9
9
|
def teardown
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_new_connectors
|
13
|
+
config.each do |db, conn_info|
|
14
|
+
case conn_info['driver']
|
15
|
+
when /cassandra/
|
16
|
+
conn = JDBCHelper::Cassandra.connect(conn_info[:host], conn_info['keyspace'])
|
17
|
+
assert conn.closed? == false
|
18
|
+
conn.close
|
19
|
+
assert conn.closed?
|
20
|
+
when /mysql/
|
21
|
+
host = conn_info['url'].match(%r{//(.*?)/?})[1]
|
22
|
+
db = conn_info['url'].match(%r{/([^/?]*?)(\?.*)?$})[1]
|
23
|
+
|
24
|
+
assert_raise(ArgumentError) {
|
25
|
+
JDBCHelper::MySQL.connect(host, conn_info['user'], conn_info['password'], db, 0)
|
26
|
+
}
|
27
|
+
assert_raise(ArgumentError) {
|
28
|
+
JDBCHelper::MySQL.connect(host, conn_info['user'], conn_info['password'], db, -1)
|
29
|
+
}
|
30
|
+
assert_raise(ArgumentError) {
|
31
|
+
JDBCHelper::MySQL.connect(host, conn_info['user'], conn_info['password'], db, "hash")
|
32
|
+
}
|
33
|
+
|
34
|
+
conn = JDBCHelper::MySQL.connect(host, conn_info['user'], conn_info['password'], db, { :timeout => 60 })
|
35
|
+
|
36
|
+
assert conn.closed? == false
|
37
|
+
conn.close
|
38
|
+
assert conn.closed?
|
39
|
+
|
40
|
+
@conn = nil
|
41
|
+
ret = JDBCHelper::MySQL.connect(host, conn_info['user'], conn_info['password'], db) do |conn|
|
42
|
+
assert conn.closed? == false
|
43
|
+
@conn = conn
|
44
|
+
1
|
45
|
+
end
|
46
|
+
assert @conn.closed?
|
47
|
+
assert_equal 1, ret
|
48
|
+
when /postgres/
|
49
|
+
host = conn_info['url'].match(%r{//([^/?]+)})[1]
|
50
|
+
db = conn_info['url'].match(%r{/([^/?]*?)(\?.*)?$})[1]
|
51
|
+
|
52
|
+
conn = JDBCHelper::Postgres.connect(host, conn_info['user'], conn_info['password'], db)
|
53
|
+
|
54
|
+
assert conn.closed? == false
|
55
|
+
conn.close
|
56
|
+
assert conn.closed?
|
57
|
+
|
58
|
+
@conn = nil
|
59
|
+
ret = JDBCHelper::PostgreSQL.connect(host, conn_info['user'], conn_info['password'], db) do |conn|
|
60
|
+
assert conn.closed? == false
|
61
|
+
@conn = conn
|
62
|
+
1
|
63
|
+
end
|
64
|
+
assert @conn.closed?
|
65
|
+
assert_equal 1, ret
|
66
|
+
when /sqlserver/
|
67
|
+
host = conn_info['url'].match(%r{//([^;]+)})[1]
|
68
|
+
db = conn_info['url'].match(%r{databaseName=([^;]+)})[1]
|
69
|
+
|
70
|
+
conn = JDBCHelper::SqlServer.connect(host, conn_info['user'], conn_info['password'], db)
|
71
|
+
|
72
|
+
assert conn.closed? == false
|
73
|
+
conn.close
|
74
|
+
assert conn.closed?
|
75
|
+
|
76
|
+
@conn = nil
|
77
|
+
ret = JDBCHelper::MSSQL.connect(host, conn_info['user'], conn_info['password'], db) do |conn|
|
78
|
+
assert conn.closed? == false
|
79
|
+
@conn = conn
|
80
|
+
1
|
81
|
+
end
|
82
|
+
assert @conn.closed?
|
83
|
+
assert_equal 1, ret
|
84
|
+
when /oracle/
|
85
|
+
host = conn_info['url'].match(%r{@(.*?)/})[1]
|
86
|
+
svc = conn_info['url'].match(%r{/([^/?]*?)(\?.*)?$})[1]
|
87
|
+
conn = JDBCHelper::Oracle.connect(host, conn_info['user'], conn_info['password'], svc)
|
88
|
+
conn2 = JDBCHelper::Oracle.connect_by_sid(host + ':1521', conn_info['user'], conn_info['password'], svc)
|
89
|
+
|
90
|
+
[conn, conn2].each do |c|
|
91
|
+
assert c.closed? == false
|
92
|
+
c.close
|
93
|
+
assert c.closed?
|
94
|
+
end
|
95
|
+
|
96
|
+
@conn = nil
|
97
|
+
ret = JDBCHelper::Oracle.connect(host, conn_info['user'], conn_info['password'], svc) do |conn|
|
98
|
+
assert conn.closed? == false
|
99
|
+
@conn = conn
|
100
|
+
1
|
101
|
+
end
|
102
|
+
assert @conn.closed?
|
103
|
+
assert_equal 1, ret
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
12
108
|
def test_connectors
|
13
|
-
config.each do |
|
109
|
+
config.each do |db, conn_info|
|
14
110
|
case conn_info['driver']
|
15
111
|
when /mysql/
|
16
112
|
host = conn_info['url'].match(%r{//(.*?)/?})[1]
|
metadata
CHANGED
@@ -1,174 +1,145 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jdbc-helper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.7.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.7.4
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Junegunn Choi
|
9
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Junegunn Choi
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :development
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rcov
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.9'
|
69
|
-
none: false
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ~>
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0.9'
|
75
|
-
none: false
|
76
|
-
prerelease: false
|
77
|
-
type: :development
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: test-unit
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - ! '>='
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: 2.3.0
|
85
|
-
none: false
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ! '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 2.3.0
|
91
|
-
none: false
|
92
|
-
prerelease: false
|
93
|
-
type: :development
|
12
|
+
|
13
|
+
date: 2012-07-09 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: insensitive_hash
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.2.4
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.4
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rcov
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0.9"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: test-unit
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.3.0
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
94
59
|
description: A JDBC helper for JRuby/Database developers.
|
95
|
-
email:
|
60
|
+
email:
|
61
|
+
- junegunn.c@gmail.com
|
96
62
|
executables: []
|
63
|
+
|
97
64
|
extensions: []
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
files:
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
- lib/jdbc-helper
|
111
|
-
- lib/jdbc-helper/
|
112
|
-
- lib/jdbc-helper/
|
113
|
-
- lib/jdbc-helper/
|
114
|
-
- lib/jdbc-helper/
|
115
|
-
- lib/jdbc-helper/
|
116
|
-
- lib/jdbc-helper/
|
117
|
-
- lib/jdbc-helper/
|
118
|
-
- lib/jdbc-helper/
|
119
|
-
- lib/jdbc-helper/
|
120
|
-
- lib/jdbc-helper/
|
121
|
-
- lib/jdbc-helper/
|
122
|
-
- lib/jdbc-helper/
|
123
|
-
- lib/jdbc-helper/
|
124
|
-
- lib/jdbc-helper/
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
- test/
|
136
|
-
|
137
|
-
|
138
|
-
-
|
139
|
-
|
65
|
+
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- CHANGELOG.markdown
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.markdown
|
74
|
+
- Rakefile
|
75
|
+
- VERSION
|
76
|
+
- jdbc-helper.gemspec
|
77
|
+
- lib/jdbc-helper.rb
|
78
|
+
- lib/jdbc-helper/connection.rb
|
79
|
+
- lib/jdbc-helper/connection/callable_statement.rb
|
80
|
+
- lib/jdbc-helper/connection/parameterized_statement.rb
|
81
|
+
- lib/jdbc-helper/connection/prepared_statement.rb
|
82
|
+
- lib/jdbc-helper/connection/result_set_enumerator.rb
|
83
|
+
- lib/jdbc-helper/connection/row.rb
|
84
|
+
- lib/jdbc-helper/connection/statement_pool.rb
|
85
|
+
- lib/jdbc-helper/connection/type_map.rb
|
86
|
+
- lib/jdbc-helper/connector.rb
|
87
|
+
- lib/jdbc-helper/connector/cassandra.rb
|
88
|
+
- lib/jdbc-helper/connector/mssql.rb
|
89
|
+
- lib/jdbc-helper/connector/mysql.rb
|
90
|
+
- lib/jdbc-helper/connector/oracle.rb
|
91
|
+
- lib/jdbc-helper/connector/postgresql.rb
|
92
|
+
- lib/jdbc-helper/constants.rb
|
93
|
+
- lib/jdbc-helper/sql/expression.rb
|
94
|
+
- lib/jdbc-helper/sql/sql.rb
|
95
|
+
- lib/jdbc-helper/sql/sql_prepared.rb
|
96
|
+
- lib/jdbc-helper/version.rb
|
97
|
+
- lib/jdbc-helper/wrapper/function_wrapper.rb
|
98
|
+
- lib/jdbc-helper/wrapper/object_wrapper.rb
|
99
|
+
- lib/jdbc-helper/wrapper/procedure_wrapper.rb
|
100
|
+
- lib/jdbc-helper/wrapper/sequence_wrapper.rb
|
101
|
+
- lib/jdbc-helper/wrapper/table_wrapper.rb
|
102
|
+
- test/database.yml
|
103
|
+
- test/helper.rb
|
104
|
+
- test/performance.rb
|
105
|
+
- test/test_connection.rb
|
106
|
+
- test/test_connectors.rb
|
107
|
+
- test/test_object_wrapper.rb
|
108
|
+
- test/test_sql.rb
|
109
|
+
- test/testrb
|
110
|
+
homepage: https://github.com/junegunn/jdbc-helper
|
111
|
+
licenses: []
|
112
|
+
|
113
|
+
post_install_message:
|
140
114
|
rdoc_options: []
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
- - ! '>='
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
segments:
|
148
|
-
- 0
|
149
|
-
hash: 2
|
150
|
-
version: '0'
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
119
|
none: false
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
125
|
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
158
130
|
requirements: []
|
159
|
-
|
160
|
-
|
161
|
-
|
131
|
+
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.8.24
|
134
|
+
signing_key:
|
162
135
|
specification_version: 3
|
163
136
|
summary: A JDBC helper for JRuby/Database developers.
|
164
|
-
test_files:
|
165
|
-
- test/database.yml
|
166
|
-
- test/
|
167
|
-
- test/
|
168
|
-
- test/
|
169
|
-
- test/
|
170
|
-
- test/
|
171
|
-
- test/
|
172
|
-
- test/
|
173
|
-
- test/testrb
|
174
|
-
...
|
137
|
+
test_files:
|
138
|
+
- test/database.yml
|
139
|
+
- test/helper.rb
|
140
|
+
- test/performance.rb
|
141
|
+
- test/test_connection.rb
|
142
|
+
- test/test_connectors.rb
|
143
|
+
- test/test_object_wrapper.rb
|
144
|
+
- test/test_sql.rb
|
145
|
+
- test/testrb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# Junegunn Choi (junegunn.c@gmail.com)
|
3
|
-
|
4
|
-
module JDBCHelper
|
5
|
-
# Shortcut connector for MySQL
|
6
|
-
class MySQLConnector < Connector
|
7
|
-
include Constants
|
8
|
-
include Constants::Connector
|
9
|
-
|
10
|
-
# @param [String] host
|
11
|
-
# @param [String] user
|
12
|
-
# @param [String] password
|
13
|
-
# @param [String] db
|
14
|
-
# @param [Fixnum] timeout
|
15
|
-
# @param [Hash] extra_params
|
16
|
-
# @return [JDBCHelper::Connection]
|
17
|
-
def self.connect(host, user, password, db,
|
18
|
-
timeout = DEFAULT_LOGIN_TIMEOUT,
|
19
|
-
extra_params = DEFAULT_PARAMETERS[:mysql], &block)
|
20
|
-
|
21
|
-
if extra_params && extra_params.is_a?(Hash) == false
|
22
|
-
raise ArgumentError.new('extra_params must be a hash')
|
23
|
-
end
|
24
|
-
|
25
|
-
conn = Connection.new(
|
26
|
-
(extra_params || {}).merge(
|
27
|
-
:driver => JDBC_DRIVER[:mysql],
|
28
|
-
:url => "jdbc:mysql://#{host}/#{db}",
|
29
|
-
:user => user,
|
30
|
-
:password => password,
|
31
|
-
:timeout => timeout))
|
32
|
-
|
33
|
-
block_given? ? ensure_close(conn, &block) : conn
|
34
|
-
end
|
35
|
-
end#MySQLConnector
|
36
|
-
end#JDBCHelper
|
37
|
-
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# Junegunn Choi (junegunn.c@gmail.com)
|
3
|
-
|
4
|
-
module JDBCHelper
|
5
|
-
# Shortcut connector for Oracle
|
6
|
-
class OracleConnector < Connector
|
7
|
-
include Constants
|
8
|
-
include Constants::Connector
|
9
|
-
|
10
|
-
# @param [String] host
|
11
|
-
# @param [String] user
|
12
|
-
# @param [String] password
|
13
|
-
# @param [String] service_name
|
14
|
-
# @param [Fixnum] timeout
|
15
|
-
# @return [JDBCHelper::Connection]
|
16
|
-
def self.connect(host, user, password, service_name, timeout = DEFAULT_LOGIN_TIMEOUT, &block)
|
17
|
-
conn = Connection.new(
|
18
|
-
:driver => JDBC_DRIVER[:oracle],
|
19
|
-
:url => "jdbc:oracle:thin:@#{host}/#{service_name}",
|
20
|
-
:user => user,
|
21
|
-
:password => password,
|
22
|
-
:timeout => timeout)
|
23
|
-
|
24
|
-
block_given? ? ensure_close(conn, &block) : conn
|
25
|
-
end
|
26
|
-
|
27
|
-
# @param [String] host
|
28
|
-
# @param [String] user
|
29
|
-
# @param [String] password
|
30
|
-
# @param [String] sid
|
31
|
-
# @param [Fixnum] timeout
|
32
|
-
# @return [JDBCHelper::Connection]
|
33
|
-
# @deprecated
|
34
|
-
def self.connect_by_sid(host, user, password, sid, timeout = DEFAULT_LOGIN_TIMEOUT, &block)
|
35
|
-
conn = Connection.new(
|
36
|
-
:driver => JDBC_DRIVER[:oracle],
|
37
|
-
:url => "jdbc:oracle:thin:@#{host}:#{sid}",
|
38
|
-
:user => user,
|
39
|
-
:password => password,
|
40
|
-
:timeout => timeout)
|
41
|
-
|
42
|
-
block_given? ? ensure_close(conn, &block) : conn
|
43
|
-
end
|
44
|
-
end#OracleConnector
|
45
|
-
end#JDBCHelper
|
46
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# Junegunn Choi (junegunn.c@gmail.com)
|
3
|
-
|
4
|
-
module JDBCHelper
|
5
|
-
# Shortcut connector for PostgreSQL
|
6
|
-
class PostgresConnector < Connector
|
7
|
-
include Constants
|
8
|
-
include Constants::Connector
|
9
|
-
|
10
|
-
# @param [String] host
|
11
|
-
# @param [String] user
|
12
|
-
# @param [String] password
|
13
|
-
# @param [String] db
|
14
|
-
# @param [Fixnum] timeout
|
15
|
-
# @param [Hash] extra_params
|
16
|
-
# @return [JDBCHelper::Connection]
|
17
|
-
def self.connect(host, user, password, db,
|
18
|
-
timeout = DEFAULT_LOGIN_TIMEOUT,
|
19
|
-
extra_params = DEFAULT_PARAMETERS[:postgres], &block)
|
20
|
-
|
21
|
-
if extra_params && extra_params.is_a?(Hash) == false
|
22
|
-
raise ArgumentError.new('extra_params must be a hash')
|
23
|
-
end
|
24
|
-
|
25
|
-
conn = Connection.new(
|
26
|
-
(extra_params || {}).merge(
|
27
|
-
:driver => JDBC_DRIVER[:postgres],
|
28
|
-
:url => "jdbc:postgresql://#{host}/#{db}",
|
29
|
-
:user => user,
|
30
|
-
:password => password,
|
31
|
-
:timeout => timeout))
|
32
|
-
|
33
|
-
block_given? ? ensure_close(conn, &block) : conn
|
34
|
-
end
|
35
|
-
end#PostgresConnector
|
36
|
-
end#JDBCHelper
|
37
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# Junegunn Choi (junegunn.c@gmail.com)
|
3
|
-
|
4
|
-
module JDBCHelper
|
5
|
-
# Shortcut connector for MS SQL Server
|
6
|
-
class SqlServerConnector < Connector
|
7
|
-
include Constants
|
8
|
-
include Constants::Connector
|
9
|
-
|
10
|
-
# @param [String] host
|
11
|
-
# @param [String] user
|
12
|
-
# @param [String] password
|
13
|
-
# @param [String] db
|
14
|
-
# @param [Fixnum] timeout
|
15
|
-
# @param [Hash] extra_params
|
16
|
-
# @return [JDBCHelper::Connection]
|
17
|
-
def self.connect(host, user, password, db,
|
18
|
-
timeout = DEFAULT_LOGIN_TIMEOUT,
|
19
|
-
extra_params = DEFAULT_PARAMETERS[:sqlserver], &block)
|
20
|
-
|
21
|
-
if extra_params && extra_params.is_a?(Hash) == false
|
22
|
-
raise ArgumentError.new('extra_params must be a hash')
|
23
|
-
end
|
24
|
-
|
25
|
-
conn = Connection.new(
|
26
|
-
(extra_params || {}).merge(
|
27
|
-
:driver => JDBC_DRIVER[:sqlserver],
|
28
|
-
:url => "jdbc:sqlserver://#{host};databaseName=#{db};",
|
29
|
-
:user => user,
|
30
|
-
:password => password,
|
31
|
-
:timeout => timeout))
|
32
|
-
|
33
|
-
block_given? ? ensure_close(conn, &block) : conn
|
34
|
-
end
|
35
|
-
end#SqlServerConnector
|
36
|
-
end#JDBCHelper
|
37
|
-
|
data/test/database.yml.local
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
mysql:
|
3
|
-
driver: com.mysql.jdbc.Driver
|
4
|
-
url: jdbc:mysql://localhost/test
|
5
|
-
database: test
|
6
|
-
user: root
|
7
|
-
password:
|
8
|
-
timeout: 5
|
9
|
-
useServerPrepStmts: true
|
10
|
-
|
11
|
-
oracle:
|
12
|
-
driver: oracle.jdbc.driver.OracleDriver
|
13
|
-
url: jdbc:oracle:thin:@10.20.253.105/didev
|
14
|
-
database: wisefn
|
15
|
-
user: wisefn
|
16
|
-
password: wisefndb
|
17
|
-
timeout: 5
|
18
|
-
|
19
|
-
postgres:
|
20
|
-
driver: org.postgresql.Driver
|
21
|
-
url: jdbc:postgresql://localhost/test
|
22
|
-
database: test
|
23
|
-
timeout: 5
|
24
|
-
stringtype: unspecified
|
25
|
-
|
26
|
-
sqlserver:
|
27
|
-
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
28
|
-
url: jdbc:sqlserver://192.168.62.26;databaseName=gunn_db;
|
29
|
-
user: gunn
|
30
|
-
password: gunn
|
31
|
-
|