rubeus 0.0.6-java → 0.0.7-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/Rakefile +26 -0
  2. data/examples/jdbc_example.rb +5 -24
  3. data/lib/rubeus.jar +0 -0
  4. data/lib/rubeus.rb +18 -2
  5. data/lib/rubeus/component_loader.rb +25 -20
  6. data/lib/rubeus/extensions.rb +44 -4
  7. data/lib/rubeus/extensions/java/awt/dimension.rb +8 -2
  8. data/lib/rubeus/extensions/java/sql/driver_manager.rb +240 -1
  9. data/lib/rubeus/extensions/javax/swing/j_table.rb +7 -23
  10. data/lib/rubeus/extensions/javax/swing/table/default_table_model.rb +7 -0
  11. data/lib/rubeus/extensions/javax/swing/table/readonlyable_table_model.rb +10 -0
  12. data/lib/rubeus/jdbc.rb +5 -0
  13. data/lib/rubeus/swing.rb +9 -6
  14. data/lib/rubeus/verboseable.rb +41 -0
  15. data/rmaven.yml +6 -0
  16. data/test/rubeus/awt/test_attributes.rb +58 -0
  17. data/test/rubeus/awt/test_event.rb +216 -0
  18. data/test/rubeus/awt/test_nestable.rb +92 -0
  19. data/test/rubeus/awt/test_setter.rb +42 -0
  20. data/test/rubeus/extensions/java/awt/test_dimension.rb +67 -0
  21. data/test/rubeus/extensions/java/sql/test_connection.rb +50 -0
  22. data/test/rubeus/extensions/java/sql/test_driver_manager.rb +37 -0
  23. data/test/rubeus/extensions/java/sql/test_result_set.rb +67 -0
  24. data/test/rubeus/extensions/java/sql/test_result_set_meta_data.rb +121 -0
  25. data/test/rubeus/extensions/java/sql/test_statement.rb +43 -0
  26. data/test/rubeus/extensions/javax/swing/table/test_default_table_model.rb +359 -0
  27. data/test/rubeus/extensions/javax/swing/table/test_default_table_model/nhk_words.xml +15 -0
  28. data/test/rubeus/extensions/javax/swing/test_box_layout.rb +56 -0
  29. data/test/rubeus/extensions/javax/swing/test_j_component.rb +30 -0
  30. data/test/rubeus/extensions/javax/swing/test_j_frame.rb +42 -0
  31. data/test/rubeus/extensions/javax/swing/test_j_panel.rb +23 -0
  32. data/test/rubeus/extensions/javax/swing/test_j_scroll_pane.rb +24 -0
  33. data/test/rubeus/extensions/javax/swing/test_j_split_pane.rb +54 -0
  34. data/test/rubeus/extensions/javax/swing/test_j_tabbed_pane.rb +204 -0
  35. data/test/rubeus/extensions/javax/swing/test_j_table.rb +71 -0
  36. data/test/rubeus/extensions/javax/swing/test_j_text_field.rb +48 -0
  37. data/test/rubeus/extensions/javax/swing/test_timer.rb +28 -0
  38. data/test/rubeus/test_extensions.rb +44 -0
  39. data/test/test_all.rb +2 -0
  40. metadata +50 -16
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ require 'rubygems'
6
+ require 'rmaven'
7
+ require 'tasks/mvn'
8
+
9
+ desc 'Default: run unit tests.'
10
+ task :default => :test
11
+
12
+ desc 'Test the selectable_attr plugin.'
13
+ Rake::TestTask.new(:test) do |t|
14
+ t.libs << File.join(File.dirname(__FILE__), 'lib')
15
+ t.pattern = File.join(File.dirname(__FILE__), 'test', 'rubeus', '**', 'test_*.rb')
16
+ t.verbose = true
17
+ end
18
+
19
+ desc 'Generate documentation for the selectable_attr plugin.'
20
+ Rake::RDocTask.new(:rdoc) do |rdoc|
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.title = 'Rubeus'
23
+ rdoc.options << '--line-numbers' << '--inline-source'
24
+ rdoc.rdoc_files.include('README')
25
+ rdoc.rdoc_files.include('lib/**/*.rb')
26
+ end
@@ -1,34 +1,15 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'java'
2
3
  require 'rubygems'
3
4
  require 'rubeus'
4
5
 
5
- def setup_derby
6
- return if ENV_JAVA['java.class.path'].split(File::PATH_SEPARATOR).any?{|path| /derby[\-\.\d]*\.jar$/ =~ path}
7
- if ENV_JAVA["java.specification.version"] == "1.6"
8
- begin
9
- require File.join(ENV_JAVA['java.home'], 'db', 'lib', 'derby.jar')
10
- return
11
- rescue LoadError
12
- # ignore error if not installed JavaDB
13
- # Apple's JDK doesn't include Apache Derby
14
- end
15
- end
16
- puts "JavaDB is not installed."
17
- puts "Please add derby.jar to your CLASSPATH."
18
- end
19
-
20
- setup_derby
21
-
22
6
  class JdbcExample
23
- include Rubeus::Jdbc
24
-
25
- def initialize
26
- # Register Driver
27
- Java::OrgApacheDerbyJdbc::EmbeddedDriver
28
- end
7
+ # includeしててもOKだけど、参照するのは基本DriverManagerしかないので、
8
+ # DriverManager => Rubeus::Jdbc::DriverManager を使うようにすればOK
9
+ # include Rubeus::Jdbc
29
10
 
30
11
  def test
31
- DriverManager.connect("jdbc:derby:test;create = true", "", "") do |con|
12
+ Rubeus::Jdbc::DriverManager.connect("jdbc:derby:test;create = true", "", "") do |con|
32
13
  con.statement do |stmt|
33
14
  # Drop table TEST if exists
34
15
  begin
Binary file
@@ -1,13 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), 'rubeus.jar')
2
+
1
3
  require "rubygems"
2
- gem "activesupport", ">=2.0.2"
4
+ gem "activesupport", "=2.1.2"
3
5
  # require "active_support"
4
6
  require "active_support/core_ext/string"
5
7
 
8
+ Kernel.module_eval <<-EOS
9
+ def jp
10
+ JavaUtilities.get_package_module_dot_format('jp')
11
+ end
12
+ EOS
13
+
6
14
  module Rubeus
7
- VERSION = "0.0.6"
15
+ VERSION = '0.0.7'
16
+ EMAIL_GROUP = 'rubeus@googlegroups.com'
17
+ WEB_SITE = 'http://code.google.com/p/rubeus/'
18
+
19
+ autoload :Verbosable, "rubeus/verboseable"
20
+
8
21
  autoload :Awt, "rubeus/awt"
9
22
  autoload :Swing, "rubeus/swing"
10
23
  autoload :Jdbc, "rubeus/jdbc"
24
+
25
+ def self.verbose; @verbose; end
26
+ def self.verbose=(value); @verbose = value; end
11
27
  end
12
28
 
13
29
  unless File.basename($PROGRAM_NAME) == 'gem' and ARGV.first == 'build'
@@ -1,6 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rubeus/verboseable'
1
3
  module Rubeus
2
4
  class ComponentLoader < Module
3
-
4
5
  def self.class_names(*package_names)
5
6
  patterns = Regexp.union(
6
7
  *package_names.map{|package_name|
@@ -15,15 +16,21 @@ module Rubeus
15
16
  classes
16
17
  end
17
18
 
19
+ include ::Rubeus::Verboseable
20
+
21
+ attr_accessor :verbose
18
22
  attr_reader :java_package
19
23
  attr_reader :class_to_package
20
24
 
21
25
  def initialize(java_package, &block)
26
+ self.verbose = Rubeus.verbose
22
27
  build_class_to_package_table(java_package)
23
28
  java_package = JavaUtilities.get_package_module_dot_format(java_package)
24
29
  class << java_package
25
30
  include Rubeus::JavaPackage
31
+ include Verboseable
26
32
  end
33
+ java_package.verbose = self.verbose
27
34
  super(&block)
28
35
  end
29
36
 
@@ -38,14 +45,14 @@ module Rubeus
38
45
  next if class_name.include?('$')
39
46
  package = parts.join('.')
40
47
  @class_to_package[class_name] = @class_to_package.key?(class_name) ?
41
- [@class_to_package[class_name], package] : package
48
+ [@class_to_package[class_name], package] : package
42
49
  end
43
50
  end
44
51
 
45
52
  def included(mod)
46
53
  mod.extend(self)
47
54
  end
48
-
55
+
49
56
  def extended(object)
50
57
  class_name_for_method = self.name.underscore.gsub('/', '_')
51
58
  const_missing_with = "const_missing_with_#{class_name_for_method}"
@@ -62,7 +69,7 @@ module Rubeus
62
69
  end
63
70
  object.extend(mod)
64
71
  object.instance_variable_set(loader_name, self)
65
- object.instance_eval <<-EOS
72
+ object.instance_eval(<<-"EOS")
66
73
  alias :#{const_missing_without} :const_missing
67
74
  alias :const_missing :#{const_missing_with}
68
75
  EOS
@@ -74,8 +81,11 @@ module Rubeus
74
81
 
75
82
  def const_missing(java_class_name)
76
83
  if autoload?(java_class_name)
84
+ log_if_verbose("autoloading... #{java_class_name.to_s}")
77
85
  feature = autolodings.delete(java_class_name.to_s)
78
- require(feature)
86
+ log_if_verbose("require(#{feature})") do
87
+ require(feature)
88
+ end
79
89
  return const_get(java_class_name)
80
90
  end
81
91
  package = @class_to_package[java_class_name.to_s]
@@ -84,12 +94,14 @@ module Rubeus
84
94
  raise NameError, "cannot specified package name for #{java_class_name}: #{package.join(', ')}"
85
95
  end
86
96
  java_fqn = package.empty? ? java_class_name.to_s : "#{package}.#{java_class_name.to_s}"
87
- result = instance_eval(java_fqn)
97
+ extension = Rubeus::Extensions.apply_for(java_fqn)
98
+ result = log_if_verbose("instance_eval(#{java_fqn})") do
99
+ instance_eval(java_fqn)
100
+ end
88
101
  self.const_set(java_class_name, result)
89
102
  result
90
103
  rescue
91
- puts $!
92
- puts $!.backtrace.join("\n ")
104
+ log_if_verbose($!)
93
105
  super
94
106
  end
95
107
 
@@ -108,36 +120,29 @@ module Rubeus
108
120
  def depend_on(*java_class_names)
109
121
  java_class_names.each{|java_class_name| self.const_get(java_class_name)}
110
122
  end
111
-
112
123
  end
113
124
 
114
125
  module JavaPackage
115
126
  def self.included(object)
116
127
  raise "JavaPackage must be extended by a Module" unless object.is_a?(Module)
117
128
  object.module_eval do
129
+ attr_accessor :verbose
118
130
  alias :method_missing_without_rubeus :method_missing
119
131
  alias :method_missing :method_missing_with_rubeus
120
132
  alias :const_missing_without_rubeus :const_missing
121
133
  alias :const_missing :const_missing_with_rubeus
122
134
  end
123
135
  end
124
-
136
+
125
137
  def method_missing_with_rubeus(method, *args)
126
138
  java_fqn = "#{@package_name}#{method.to_s}"
127
- extension = Rubeus::Extensions.find_for(java_fqn)
128
- if extension
129
- @extension_applied ||= []
130
- unless @extension_applied.include?(java_fqn)
131
- JavaUtilities.extend_proxy(java_fqn) do
132
- include extension
133
- end
134
- @extension_applied << java_fqn
135
- end
136
- end
139
+ extension = Rubeus::Extensions.apply_for(java_fqn)
137
140
  result = method_missing_without_rubeus(method, *args)
138
141
  class << result
139
142
  include ::Rubeus::JavaPackage
143
+ include Verboseable
140
144
  end
145
+ result.verbose = self.verbose
141
146
  result
142
147
  end
143
148
 
@@ -1,16 +1,33 @@
1
+ require 'rubeus/verboseable'
1
2
  module Rubeus
2
3
  module Extensions
3
4
  autoload :Java, 'rubeus/extensions/java'
4
5
  autoload :Javax, 'rubeus/extensions/javax'
5
6
 
7
+ RUBEUS_EXTRA_PACKAGE = "jp.rubybizcommons.rubeus.extensions".freeze
8
+ RUBEUS_EXTRA_PACKAGE_PARTS = RUBEUS_EXTRA_PACKAGE.split('.').freeze
9
+
6
10
  class << self
7
- def path_for(java_fqn_or_parts)
11
+ def verbose; ::Rubeus.verbose; end
12
+
13
+ private
14
+ def package_parts(java_fqn_or_parts)
8
15
  parts = java_fqn_or_parts.is_a?(Array) ? java_fqn_or_parts : java_fqn_or_parts.split('.')
16
+ if parts[0, RUBEUS_EXTRA_PACKAGE_PARTS.length] == RUBEUS_EXTRA_PACKAGE_PARTS
17
+ parts = parts[RUBEUS_EXTRA_PACKAGE_PARTS.length..-1]
18
+ end
19
+ parts
20
+ end
21
+
22
+ public
23
+
24
+ def path_for(java_fqn_or_parts)
25
+ parts = package_parts(java_fqn_or_parts)
9
26
  "rubeus/extensions/%s" % parts.map{|part|part.underscore}.join('/')
10
27
  end
11
28
 
12
29
  def class_name_for(java_fqn_or_parts)
13
- parts = java_fqn_or_parts.is_a?(Array) ? java_fqn_or_parts : java_fqn_or_parts.split('.')
30
+ parts = package_parts(java_fqn_or_parts)
14
31
  "Rubeus::Extensions::%s" % parts.map{|part|part.camelize}.join('::')
15
32
  end
16
33
 
@@ -18,18 +35,41 @@ module Rubeus
18
35
  parts = java_fqn.split('.')
19
36
  extension_path = path_for(parts)
20
37
  begin
21
- require(extension_path)
38
+ log_if_verbose("require(#{extension_path.inspect})") do
39
+ require(extension_path)
40
+ end
22
41
  rescue LoadError => e
23
42
  # puts "warning: #{e}"
24
43
  return nil
25
44
  end
26
45
  begin
27
- instance_eval(class_name_for(parts))
46
+ klass_name = class_name_for(parts)
47
+ log_if_verbose("instance_eval(#{klass_name.inspect})") do
48
+ instance_eval(klass_name)
49
+ end
28
50
  rescue NameError => e
29
51
  # puts "warning: #{e}"
30
52
  return nil
31
53
  end
32
54
  end
55
+
56
+ def apply_for(java_fqn)
57
+ log_if_verbose("apply_for(#{java_fqn.inspect})") do
58
+ extension = self.find_for(java_fqn)
59
+ return nil unless extension
60
+ @extension_applied ||= []
61
+ unless @extension_applied.include?(java_fqn)
62
+ log_if_verbose("JavaUtilities.extend_proxy(#{java_fqn})") do
63
+ JavaUtilities.extend_proxy(java_fqn) do
64
+ include extension
65
+ end
66
+ end
67
+ @extension_applied << java_fqn
68
+ end
69
+ end
70
+ end
71
+
33
72
  end
73
+ extend ::Rubeus::Verboseable
34
74
  end
35
75
  end
@@ -7,7 +7,9 @@ module Rubeus::Extensions::Java::Awt
7
7
  module ClassMethods
8
8
  def create(*args)
9
9
  values = args
10
- if args.length == 1
10
+ if args.length == 0
11
+ return new
12
+ elsif args.length == 1
11
13
  if args.first.is_a?(Array)
12
14
  return create(*args.first)
13
15
  elsif args.first.is_a?(Rubeus::Awt::Dimension)
@@ -16,7 +18,11 @@ module Rubeus::Extensions::Java::Awt
16
18
  values = args.first.to_s.split("x", 2)
17
19
  end
18
20
  end
19
- new(*values.map{|s|s.to_i})
21
+ if values.length == 2
22
+ new(*values.map{|s|s.to_i})
23
+ else
24
+ raise ArgumentError, "Unsupported arguments: #{args.inspect}"
25
+ end
20
26
  end
21
27
  end
22
28
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  Rubeus::Jdbc.depend_on("Connection")
2
3
 
3
4
  module Rubeus::Extensions::Java::Sql
@@ -8,9 +9,247 @@ module Rubeus::Extensions::Java::Sql
8
9
  end
9
10
 
10
11
  module ClassMethods
11
- def connect(url, user, password, &block)
12
+ CONNECT_DEFAULT_OPTIONS = {
13
+ :auto_setup_manager => true # trueならconnectメソッドの引数urlからドライバを探してロードします
14
+ }.freeze
15
+
16
+ def connect(url, user = '', password = '', options = CONNECT_DEFAULT_OPTIONS, &block)
17
+ setup_for(url, options) if options[:auto_setup_manager]
12
18
  with_close(get_connection(url, user, password), &block)
13
19
  end
20
+
21
+ def setup_for(url, options = nil)
22
+ DriverManager::Loader.setup_for(url, options)
23
+ end
14
24
  end
25
+
26
+ class Loader
27
+ def self.entries
28
+ @entries ||= []
29
+ end
30
+
31
+ def self.entry(name, pattern, driver, driver_type = :unknown, options = nil, &block)
32
+ result = entry_with(name) do |db|
33
+ db.pattern(pattern, driver, driver_type)
34
+ db.options = options
35
+ end
36
+ result.instance_eval(&block) if block_given?
37
+ result
38
+ end
39
+
40
+ def self.entry_with(name, &block)
41
+ result = self.new(name)
42
+ result.instance_eval(&block) if block_given?
43
+ entries << result
44
+ result
45
+ end
46
+
47
+ def self.setup_for(url, setup_options = nil)
48
+ entries.each do |entry|
49
+ driver = entry.setup_for(url, setup_options)
50
+ return driver if driver
51
+ end
52
+ raise ArgumentError, "DriverManager catalog not found for #{url}"
53
+ end
54
+
55
+ attr_reader :name
56
+
57
+ def initialize(name)
58
+ @name = name
59
+ @patterns = []
60
+ end
61
+
62
+ def pattern(pattern, driver, driver_type = :unknown)
63
+ @patterns << {:pattern => pattern, :driver => driver, :driver_type => driver_type}
64
+ end
65
+
66
+ def options
67
+ @options ||= {}
68
+ end
69
+
70
+ def options=(value)
71
+ @options = value
72
+ end
73
+
74
+ def driver_for(url, driver_type = nil)
75
+ patterns = driver_type ? @patterns.select{|pattern| pattern[:driver_type] == driver_type} : @patterns
76
+ pattern = patterns.detect{|pattern| pattern[:pattern] =~ url}
77
+ pattern ? pattern[:driver] : nil
78
+ end
79
+
80
+ def setup_for(url, setup_options = nil)
81
+ driver_name = driver_for(url)
82
+ return nil unless driver_name
83
+ begin
84
+ return JavaUtilities.get_proxy_class(driver_name)
85
+ rescue NameError => name_error
86
+ requirements = options[:gem_require]
87
+ raise name_error unless requirements
88
+ requirements = [requirements] unless requirements.is_a?(Array)
89
+ load_error_messages = []
90
+ requirements.each do |requirement|
91
+ begin
92
+ require(requirement)
93
+ rescue LoadError => load_error
94
+ msg = "failure to load '#{requirement}' of '#{options[:gem]}'."
95
+ msg << " Try 'jruby -S gem install #{options[:gem]}'" unless /\.jar$/ =~ requirement
96
+ load_error_messages << msg
97
+ next
98
+ end
99
+ begin
100
+ return JavaUtilities.get_proxy_class(driver_name)
101
+ rescue NameError => name_error_again
102
+ msg = "#{driver_name} not found for #{url}"
103
+ msg << ", but loaded '#{requirement}' of '#{options[:gem]}' successfully."
104
+ msg << " It might be a serious problem. Please let us know by email '#{Rubeus::EMAIL_GROUP}'. "
105
+ raise NameError, msg
106
+ end
107
+ end
108
+ raise LoadError, "#{driver_name} not found for #{url} because of " << load_error_messages.join(" AND ")
109
+ end
110
+ end
111
+ end
112
+
113
+ # http://wiki.paulownia.jp/java/jdbc
114
+ class Loader
115
+ # JDBC-ODBC Bridge
116
+ # (Type1) sun.jdbc.odbc.JdbcOdbcDriver
117
+ # jdbc:odbc:DataSourceName
118
+ # Type1はODBCを使用してデータベースにアクセス。ODBCドライバのインストールと
119
+ # ODBCアドミニストレータ設定が必要。DataSourceNameにはODBCで設定した名前を入れる。
120
+ entry("ODBC", /jdbc:odbc:.*/, "sun.jdbc.odbc.JdbcOdbcDriver", :type1)
121
+
122
+ # DB2
123
+ # Type2 COM.ibm.db2.jdbc.app.DB2Driver (v8.1まで)
124
+ # com.ibm.db2.jcc.DB2Driver (DB2 v8.1.2以降)
125
+ # jdbc:db2:DataSourceName
126
+ # DB2クライアントのインストールが必要。DataSourceNameには、DB2構成アシスタントで
127
+ # 設定したデータソース名を記述する。新しいドライバはType4と同じクラスで、URLでどちらのTypeを使うか区別する。
128
+ #
129
+ # DB2
130
+ # Type3 COM.ibm.db2.jdbc.net.DB2Driver
131
+ # jdbc:db2://127.0.0.1:50000/DataBaseName
132
+ # JDBC Type3ドライバのサポートは終了しており、Type4の使用が推奨されている。
133
+ #
134
+ # DB2
135
+ # Type4 com.ibm.db2.jcc.DB2Driver
136
+ # jdbc:db2://127.0.0.1:50000/DataBaseName
137
+ # DB2バージョン8.1からサポートされた。DB2クライアントのインストールは不要。
138
+ entry_with "DB2" do |db|
139
+ db.pattern(/jdbc:db2:\/\/.*\/.*/, 'com.ibm.db2.jcc.DB2Driver' , :type4)
140
+ db.pattern(/jdbc:db2:\/\/.*\/.*/, 'COM.ibm.db2.jdbc.net.DB2Driver', :type3)
141
+ db.pattern(/jdbc:db2:.*/ , 'COM.ibm.db2.jdbc.app.DB2Driver', :type2)
142
+ end
143
+
144
+ # Oracle
145
+ # Type4 oracle.jdbc.driver.OracleDriver
146
+ # jdbc:oracle:thin:@127.0.0.1:1521:SID
147
+ # オラクルは他のDBと違い、URLのプロトコルとホストの区切りが // ではなく @ となっている。
148
+ #
149
+ # Oracle
150
+ # Type2 oracle.jdbc.driver.OracleDriver
151
+ # jdbc:oracle:oci8:@TNS (for Oracle 8i)
152
+ # jdbc:oracle:oci:@TNS (for Oracle 9i or 10g)
153
+ # tnsnames.oraファイルにデータソースの設定を書く。Oracleクライアントが必要。
154
+ # 10gは9i用クライアントでも使用可能のようだ。
155
+ entry_with "Oracle" do |db|
156
+ db.pattern(/jdbc:oracle:thin:@.*(:.*)*(:.*)*/, 'oracle.jdbc.driver.OracleDriver', :type4)
157
+ db.pattern(/jdbc:oracle:oci8:@.*/ , 'oracle.jdbc.driver.OracleDriver', :type2)
158
+ db.pattern(/jdbc:oracle:oci:@.*/ , 'oracle.jdbc.driver.OracleDriver', :type2)
159
+ end
160
+
161
+ # SQL Server 2000
162
+ # Type4 com.microsoft.jdbc.sqlserver.SQLServerDriver
163
+ # jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=DBName
164
+ # MS製なのでWindows版しかないが、導入が容易でバランスのとれたチューニングが施されている。
165
+ # このドライバはMSDE 2000でも使用可能。
166
+ entry("SQL Server 2000", /jdbc:microsoft:sqlserver:.*/, "com.microsoft.jdbc.sqlserver.SQLServerDriver", :type4)
167
+
168
+ # SQL Server 2005
169
+ # Type4 com.microsoft.sqlserver.jdbc.SQLServerDriver
170
+ # jdbc:sqlserver://localhost:1433;DatabaseName=DBName
171
+ # SQLServer 2005。旧バージョンからドライバクラスもURLも微妙に変更されているので注意。参考
172
+ entry("SQL Server 2005", /jdbc:sqlserver:.*/, "com.microsoft.sqlserver.jdbc.SQLServerDriver", :type4)
173
+
174
+ # Firebird
175
+ # Type 4 org.firebirdsql.jdbc.FBDriver
176
+ # jdbc:firebirdsql://127.0.0.1:3050/DataBasePath
177
+ # オープンソースのRDB。DataBasePathにはサーバ上のデータベースファイル(.gdb)への絶対パスを指定するらしい。
178
+ entry("Firebird", /jdbc:firebirdsql:.*/, "org.firebirdsql.jdbc.FBDriver", :type4)
179
+
180
+ # MySQL
181
+ # Type 4 com.mysql.jdbc.Driver
182
+ # jdbc:mysql://127.0.0.1:3306/DBName
183
+ # GPLライセンスと商用ライセンスで利用できるRDB。Movable Type等のBlogツールでも採用されている。
184
+ entry("MySQL", /jdbc:mysql:.*/, "com.mysql.jdbc.Driver", :type4,
185
+ :gem => "jdbc-mysql", :gem_require => "jdbc/mysql")
186
+
187
+ # PostgreSQL
188
+ # Type 4 org.postgresql.Driver
189
+ # jdbc:postgresql://127.0.0.1:5432/DBName
190
+ # BSDライセンスで配布されており、商用でも無償で使用可能。中小規模システム、個人用DBとしてMySQLと並んで人気。
191
+ entry("PostgreSQL", /jdbc:postgresql:.*/, "org.postgresql.Driver", :type4,
192
+ :gem => "jdbc-postgres", :gem_require => "jdbc/postgres")
193
+
194
+ # HSQLDB org.hsqldb.jdbcDriver
195
+ # jdbc:hsqldb:hsql://127.0.0.1:9001/databasename
196
+ # 高速、軽量、Pure Javaの組み込み向けRDBMS。jarファイル一つで動作する。このURLはサーバモードで起動したHSQLDBにアクセスするURL。
197
+ #
198
+ # org.hsqldb.jdbcDriver
199
+ # jdbc:hsqldb:file:databasename
200
+ # HSQLDBをインプロセスモードで起動する。javaアプリケーションと同じVM上で起動し、組み込みのデータベースとして使う。
201
+ # 終了時にSHUTDOWN命令を送らないとデータが永続化されない。URLの最後に;shutdown=trueを付加すると終了時にデータが自動的に保存される。
202
+ #
203
+ # org.hsqldb.jdbcDriver
204
+ # jdbc:hsqldb:mem:databasename
205
+ # HSQLDBをインメモリモードで起動する。インメモリモードはスタンドアロンモードと同じだがデータを永続化しない。JavaVMを終了するとデータが失われる。
206
+ entry_with "HSQLDB" do |db|
207
+ db.pattern(/jdbc:hsqldb:hsql:.*/, "org.hsqldb.jdbcDriver")
208
+ db.pattern(/jdbc:hsqldb:file:.*/, "org.hsqldb.jdbcDriver")
209
+ db.pattern(/jdbc:hsqldb:mem:.*/ , "org.hsqldb.jdbcDriver")
210
+ db.options = {:gem => "jdbc-hsqldb", :gem_require => "jdbc/hsqldb"}
211
+ end
212
+
213
+ # Derby org.apache.derby.jdbc.EmbeddedDriver
214
+ # jdbc:derby:databasename;create=true
215
+ # Java言語で書かれた組み込み用のデータベース。create=trueはオプションで、databasenameが見つからない場合に新規データベースを作成する。
216
+ entry("Derby", /jdbc:derby:.*/, "org.apache.derby.jdbc.EmbeddedDriver", :unknown,
217
+ :gem => 'jdbc-derby', :gem_require => [
218
+ 'jdbc/derby',
219
+ (ENV_JAVA['java.specification.version'] > '1.5' ? File.join(ENV_JAVA['java.home'], 'db', 'lib', 'derby.jar') : nil)
220
+ ].compact)
221
+
222
+ # OpenBase
223
+ # Type4 com.openbase.jdbc.ObDriver
224
+ # jdbc:openbase://localhost/DataBaseName
225
+ # MacOSXの前身NEXTSTEP/OPENSTEP上で開発されたRDBMSらしい。Linux版、Windows版もあるようだ。
226
+ entry("OpenBase", /jdbc:openbase:.*/, "com.openbase.jdbc.ObDriver", :type4)
227
+
228
+ # H2 org.h2.Driver
229
+ # jdbc:h2:tcp://localhost:9092/DataBasePath
230
+ # HSQLの開発者が作成した組み込みDB。DBをサーバとして起動した場合のURL。
231
+ # org.h2.Driver
232
+ # jdbc:h2:DataBasePath
233
+ # 組み込みDBとして使用する場合のURL。
234
+ entry_with "H2" do |db|
235
+ db.pattern(/jdbc:h2:tcp:.*/, "org.h2.Driver")
236
+ db.pattern(/jdbc:h2:.*/ , "org.h2.Driver")
237
+ db.options = {:gem => "jdbc-h2", :gem_require => "jdbc/h2"}
238
+ end
239
+
240
+ # Sybase ASE
241
+ # Type4 com.sybase.jdbc.SybDriver
242
+ # jdbc:sybase:Tds:localhost:8001/databasename
243
+ # 一時期MSSQLServerとして提供されていたこともあるRDBMS。そのためか両製品をサポートしているサードパーティ製やオープンソースのドライバがある。
244
+ entry("Sybase ASE", /jdbc:sybase:Tds:.*/, "com.sybase.jdbc.SybDriver", :type4)
245
+
246
+ # SQLite
247
+ # Type4(?) org.sqlite.JDBC
248
+ # jdbc:sqlite:databasefile_path
249
+ # SQLiteにアクセスするJDBCドライバ。NestedVMというものをつかってPure Javaのドライバとしている?らしい…
250
+ entry("SQLite", /jdbc:sqlite:.*/, "org.sqlite.JDBC", :type4,
251
+ :gem => "jdbc-sqlite3", :gem_require => "jdbc/sqlite3")
252
+ end
253
+
15
254
  end
16
255
  end