jfb 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9eb1b5b0e01579dd466716b80a819ffb4c5f64ea
4
- data.tar.gz: 27e9fd75fda5626bc6a0e746267033fcfb06e87d
3
+ metadata.gz: 491052289fc4051583763f2a4a72a2c3f7dd12e8
4
+ data.tar.gz: e76743290755e60e18c9c437bb184c793795e652
5
5
  SHA512:
6
- metadata.gz: 71ffa534d86ca29952da227ab0e33cbf9c02194d912b75bad4736ae382b20c1b546ae43536a726ecda0890252b1fcd48132a39ecaf57d16a748892f69600da97
7
- data.tar.gz: 34671b0ecd0d634730a66dd94be272eac00e09b08f0ebea482a10f0d43314c4f74cf5bcf0ac11ff49de598566f308553e342291d1786a061de522459c1b10c0a
6
+ metadata.gz: 2ab5306f46cb675b31e307c100e5d7c2cbf00fd989cbcbd3c9b623c5186860698907cf9320c3d58d6c2c774e20d0f097106b7316a2cd93fd05d7ce6aa6e981f9
7
+ data.tar.gz: c8bbf92f189e6e4bdf06d0151cae74c98e50db3a991fd8cfa744af3a526637943183afe5445566775af0fdab33287d4e878fa1b07ceaea5d6dc179188e44d822
@@ -1,5 +1,6 @@
1
- require_relative 'jaybird-2.2.12.jar'
1
+ require_relative 'jaybird-full-2.2.14.jar'
2
2
  java_import 'java.sql.ResultSet'
3
+ java_import 'java.sql.Connection'
3
4
  java_import 'java.sql.SQLRecoverableException'
4
5
 
5
6
  class JFB
@@ -15,7 +16,7 @@ class JFB
15
16
  @con = nil
16
17
  end
17
18
 
18
- def connect()
19
+ def connect(attr={})
19
20
  if @closed then
20
21
  @con = nil
21
22
 
@@ -29,7 +30,39 @@ class JFB
29
30
  begin
30
31
  @con = @fbd.connect("jdbc:firebirdsql:#{@url}", props)
31
32
  @con.set_auto_commit false
32
- @con.set_holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
33
+
34
+ if attr[:holdability] != nil then
35
+ case attr[:holdability]
36
+ when :hcoc
37
+ @con.set_holdability java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT
38
+ when :ccac
39
+ @con.set_holdability java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT
40
+ else
41
+ end
42
+ end
43
+
44
+ if attr[:transaction_isolation] != nil
45
+ case
46
+ when :tru
47
+ @con.set_transaction_isolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED)
48
+
49
+ when :trc
50
+ @con.set_transaction_isolation(java.sql.Connection.TRANSACTION_READ_COMMITTED)
51
+
52
+ when :trr
53
+ @con.set_transaction_isolation(java.sql.Connection.TRANSACTION_REPEATABLE_READ)
54
+
55
+ when :ts
56
+ @con.set_transaction_isolation(java.sql.Connection.TRANSACTION_SERIALIZABLE)
57
+
58
+ when :tn
59
+ @con.set_transaction_isolation(java.sql.Connection.TRANSACTION_NONE)
60
+
61
+ else
62
+ end
63
+ end
64
+
65
+ @properties = attr
33
66
  @closed = false
34
67
 
35
68
  rescue SQLRecoverableException => erro
@@ -49,10 +82,20 @@ class JFB
49
82
  end
50
83
  end
51
84
 
85
+ def create_statement()
86
+ st = @con.createStatement()
87
+
88
+ if @properties[:query_timeout] != nil then
89
+ st.set_query_timeout(@properties[:query_timeout])
90
+ end
91
+
92
+ st
93
+ end
94
+
52
95
  def query(cmd)
53
96
  if not @closed then
54
97
  begin
55
- return convert_rs_to_array(@con.createStatement().executeQuery(cmd))
98
+ return convert_rs_to_array(create_statement.executeQuery(cmd))
56
99
  rescue Exception => erro
57
100
  puts "Error message while querying:\n#{erro}\nQuery: #{cmd}"
58
101
  end
@@ -64,7 +107,7 @@ class JFB
64
107
  def update(cmd)
65
108
  if not @closed then
66
109
  begin
67
- @con.createStatement().executeUpdate(cmd)
110
+ create_statement.executeUpdate(cmd)
68
111
  rescue Exception => erro
69
112
  puts "Error message while updating:\n#{erro}\nUpdate: #{cmd}"
70
113
  end
@@ -116,6 +159,8 @@ class JFB
116
159
  k = k + 1
117
160
  end
118
161
 
162
+ rs.close
163
+
119
164
  res
120
165
  end
121
166
  end
@@ -1,5 +1,5 @@
1
1
  module Jfb
2
- VERSION = "0.5.1"
2
+ VERSION = "1.0.0"
3
3
 
4
4
  #What the numbers mean: rr.ff.hh
5
5
  # rr: Major releases and changes in the project;
@@ -63,4 +63,7 @@ module Jfb
63
63
  #Version 0.5.1
64
64
  # Implements a simple test to interact with a database in my envyro.
65
65
  # Fixes wrong column refference.
66
+
67
+ #Version 1.0.0
68
+ # Enables setting up of connection, resultset and querie properties.
66
69
  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.5.1
4
+ version: 1.0.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-10-18 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ files:
72
72
  - bin/setup
73
73
  - jfb.gemspec
74
74
  - lib/jfb.rb
75
- - lib/jfb/jaybird-2.2.12.jar
75
+ - lib/jfb/jaybird-full-2.2.14.jar
76
76
  - lib/jfb/jfb.rb
77
77
  - lib/jfb/version.rb
78
78
  homepage: https://github.com/rCamposCruz/jfb