-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_mysql.rb
69 lines (55 loc) · 1.41 KB
/
do_mysql.rb
1
2
3
4
5
6
7
8
9
10
11
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
60
61
62
63
64
65
66
67
68
69
require 'data_objects'
if RUBY_PLATFORM =~ /java/
require 'do_jdbc'
require 'java'
module DataObjects
module Mysql
JDBC_DRIVER = 'com.mysql.jdbc.Driver'
end
end
begin
java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Mysql::JDBC_DRIVER, true)
rescue java.lang.ClassNotFoundException
require 'jdbc/mysql' # the JDBC driver, packaged as a gem
Jdbc::MySQL.load_driver if Jdbc::MySQL.respond_to?(:load_driver)
end
# Another way of loading the JDBC Class. This seems to be more reliable
# than Class.forName() or
# Thread.currentThread.getContextClassLoader().loadClass() within the
# data_objects.Connection Java class, which is currently not working as
# expected.
java_import DataObjects::Mysql::JDBC_DRIVER
end
begin
require 'do_mysql/do_mysql'
rescue LoadError
if RUBY_PLATFORM =~ /mingw|mswin/
RUBY_VERSION =~ /(\d+.\d+)/
require "do_mysql/#{$1}/do_mysql"
else
raise
end
end
require 'do_mysql/version'
require 'do_mysql/transaction' if RUBY_PLATFORM !~ /java/
require 'do_mysql/encoding'
if RUBY_PLATFORM =~ /java/
DataObjects::Mysql::Connection.class_eval do
def using_socket?
@using_socket
end
def secure?
false
end
end
else
module DataObjects
module Mysql
class Connection
def secure?
!(@ssl_cipher.nil? || @ssl_cipher.empty?)
end
end
end
end
end