jfb 0.4.11 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jfb/jfb.rb +35 -8
- data/lib/jfb/version.rb +4 -1
- metadata +2 -3
- data/lib/jfb/rs.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ea104d6054c38a94c66eb26206a27e33fcb74d7
|
4
|
+
data.tar.gz: 9b63e3e408d39bbabae9aafa40f03fbcf32fb54b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc68910f37c4b4d536cc9d1169ce472fc517cf3c25507b5eb315ab98b326054a410a61fd8f46328bcdc1fc5b69bab25ad3527a4c78ce566e260d745a10404fb
|
7
|
+
data.tar.gz: 152f5fdbb67eb4e8fa856d9d56dfcc629893ce6e71d996c8679ca3e9c0b2152b46bab6b5d56c7e3ccfd6a66091b12daa0851dc295e8453a78e8106ef211470c9
|
data/lib/jfb/jfb.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require_relative 'rs'
|
2
1
|
require_relative 'jaybird-2.2.12.jar'
|
3
2
|
java_import 'java.sql.ResultSet'
|
4
3
|
java_import 'java.sql.SQLRecoverableException'
|
@@ -8,19 +7,27 @@ class JFB
|
|
8
7
|
|
9
8
|
def initialize(db_url, usr, pwd)
|
10
9
|
Java::JavaClass.for_name("org.firebirdsql.jdbc.FBDriver")
|
11
|
-
fbd = org.firebirdsql.jdbc.FBDriver.new
|
10
|
+
@fbd = org.firebirdsql.jdbc.FBDriver.new
|
11
|
+
@url = db_url
|
12
|
+
@usr = usr
|
13
|
+
@pwd = pwd
|
12
14
|
@closed = true
|
13
15
|
@con = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def connect()
|
19
|
+
if @closed then
|
20
|
+
@con = nil
|
14
21
|
|
15
|
-
if fbd.acceptsURL("jdbc:firebirdsql:#{
|
22
|
+
if @fbd.acceptsURL("jdbc:firebirdsql:#{@url}") then
|
16
23
|
Java::JavaClass.for_name("java.util.Properties")
|
17
24
|
|
18
25
|
props = java.util.Properties.new
|
19
|
-
props.set_property :user, usr
|
20
|
-
props.set_property :password, pwd
|
26
|
+
props.set_property :user, @usr
|
27
|
+
props.set_property :password, @pwd
|
21
28
|
|
22
29
|
begin
|
23
|
-
@con = fbd.connect("jdbc:firebirdsql:#{
|
30
|
+
@con = @fbd.connect("jdbc:firebirdsql:#{@url}", props)
|
24
31
|
@con.set_auto_commit false
|
25
32
|
@con.set_holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
|
26
33
|
@closed = false
|
@@ -33,16 +40,19 @@ class JFB
|
|
33
40
|
else
|
34
41
|
@con = nil
|
35
42
|
@closed = true
|
36
|
-
puts "Database URI #{
|
43
|
+
puts "Database URI #{@url} isn't acceptable.
|
37
44
|
You don't have to supply the 'jdbc:firebirsql:' part,
|
38
45
|
we already do that. Please check your URI."
|
39
46
|
end
|
47
|
+
|
48
|
+
@closed = false
|
49
|
+
end
|
40
50
|
end
|
41
51
|
|
42
52
|
def query(cmd)
|
43
53
|
if not @closed then
|
44
54
|
begin
|
45
|
-
return
|
55
|
+
return convert_rs_to_array(@con.createStatement().executeQuery(cmd))
|
46
56
|
rescue Exception => erro
|
47
57
|
puts "Error message while querying:\n#{erro}\nQuery: #{cmd}"
|
48
58
|
end
|
@@ -87,4 +97,21 @@ class JFB
|
|
87
97
|
@closed = true
|
88
98
|
end
|
89
99
|
end
|
100
|
+
|
101
|
+
def convert_rs_to_array(rs)
|
102
|
+
res = []
|
103
|
+
k = 0
|
104
|
+
|
105
|
+
while rs.next do
|
106
|
+
cols = rs.metada_data().get_column.count()
|
107
|
+
|
108
|
+
(0..cols - 1).each do |i|
|
109
|
+
res[k][i] = rs.get_string(i)
|
110
|
+
end
|
111
|
+
|
112
|
+
k = k + 1
|
113
|
+
end
|
114
|
+
|
115
|
+
res
|
116
|
+
end
|
90
117
|
end
|
data/lib/jfb/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Jfb
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.5.0"
|
3
3
|
|
4
4
|
#What the numbers mean: rr.ff.hh
|
5
5
|
# rr: Major releases and changes in the project;
|
@@ -56,4 +56,7 @@ module Jfb
|
|
56
56
|
|
57
57
|
#Version 0.4.11
|
58
58
|
# Rollback Jaybird version to 2.2.12
|
59
|
+
|
60
|
+
#Version 0.5.0
|
61
|
+
# Implements standard rs to matrix conversion
|
59
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jfb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rCamposCruz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- lib/jfb.rb
|
75
75
|
- lib/jfb/jaybird-2.2.12.jar
|
76
76
|
- lib/jfb/jfb.rb
|
77
|
-
- lib/jfb/rs.rb
|
78
77
|
- lib/jfb/version.rb
|
79
78
|
homepage: https://github.com/rCamposCruz/jfb
|
80
79
|
licenses:
|
data/lib/jfb/rs.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'java'
|
2
|
-
|
3
|
-
class RS
|
4
|
-
def initialize(result_set)
|
5
|
-
@my_rs = result_set
|
6
|
-
end
|
7
|
-
|
8
|
-
def absolute(row)
|
9
|
-
@my_rs.absolute(row)
|
10
|
-
end
|
11
|
-
|
12
|
-
def next
|
13
|
-
return @my_rs.next()
|
14
|
-
end
|
15
|
-
|
16
|
-
def previous
|
17
|
-
return @my_rs.previous()
|
18
|
-
end
|
19
|
-
|
20
|
-
def close
|
21
|
-
if not is_closed?
|
22
|
-
@my_rs.close()
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def is_closed?
|
27
|
-
return @my_rs.isClosed()
|
28
|
-
end
|
29
|
-
|
30
|
-
def is_last?
|
31
|
-
return @my_rs.isLast()
|
32
|
-
end
|
33
|
-
|
34
|
-
def is_first?
|
35
|
-
return @my_rs.isFirst()
|
36
|
-
end
|
37
|
-
|
38
|
-
def before_first
|
39
|
-
return @my_rs.beforeFirst()
|
40
|
-
end
|
41
|
-
|
42
|
-
def after_last
|
43
|
-
return @my_rs.afterLast()
|
44
|
-
end
|
45
|
-
|
46
|
-
def first
|
47
|
-
return @my_rs.first()
|
48
|
-
end
|
49
|
-
|
50
|
-
def last
|
51
|
-
return @my_rs.last()
|
52
|
-
end
|
53
|
-
|
54
|
-
def get_row
|
55
|
-
return @my_rs.getRow()
|
56
|
-
end
|
57
|
-
|
58
|
-
def get_int(identifier)
|
59
|
-
return @my_rs.getInt(identifier)
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_double(identifier)
|
63
|
-
return @my_rs.getDouble(identifier)
|
64
|
-
end
|
65
|
-
|
66
|
-
def get_string(identifier)
|
67
|
-
return @my_rs.getString(identifier)
|
68
|
-
end
|
69
|
-
|
70
|
-
def get_date(identifier)
|
71
|
-
return @my_rs.getDate(identifier)
|
72
|
-
end
|
73
|
-
end
|