Module: Sequel::JDBC
- Defined in:
- lib/sequel_core/adapters/jdbc.rb,
lib/sequel_core/adapters/jdbc/mysql.rb,
lib/sequel_core/adapters/jdbc/oracle.rb,
lib/sequel_core/adapters/jdbc/sqlite.rb
Overview
Houses Sequel’s JDBC support when running on JRuby. Support for individual database types is done using sub adapters. PostgreSQL, MySQL, SQLite, Oracle, and MSSQL all have relatively good support, close the the level supported by the native adapter. PostgreSQL, MySQL, SQLite can load necessary support using the jdbc-* gem, if it is installed, though they will work if you have the correct .jar in your CLASSPATH. Oracle and MSSQL should load the necessary support if you have the .jar in your CLASSPATH. For all other databases, the Java class should be loaded manually before calling Sequel.connect.
Note that when using a JDBC adapter, the best way to use Sequel is via Sequel.connect, NOT Sequel.jdbc. Use the JDBC connection string when connecting, which will be in a different format than the native connection string. The connection string should start with ‘jdbc:’. For PostgreSQL, use ‘jdbc:postgresql:’, and for SQLite you do not need 2 preceding slashes for the database name (use no preceding slashes for a relative path, and one preceding slash for an absolute path).
Defined Under Namespace
Modules: JavaLang, JavaSQL, MySQL, Oracle, SQLite Classes: Database, Dataset
Constant Summary collapse
- DATABASE_SETUP =
Contains procs keyed on sub adapter type that extend the given database object so it supports the correct database type.
{:postgresql=>proc do |db| require 'sequel_core/adapters/jdbc/postgresql' db.extend(Sequel::JDBC::Postgres::DatabaseMethods) JDBC.load_gem('postgres') org.postgresql.Driver end, :mysql=>proc do |db| require 'sequel_core/adapters/jdbc/mysql' db.extend(Sequel::JDBC::MySQL::DatabaseMethods) JDBC.load_gem('mysql') com.mysql.jdbc.Driver end, :sqlite=>proc do |db| require 'sequel_core/adapters/jdbc/sqlite' db.extend(Sequel::JDBC::SQLite::DatabaseMethods) JDBC.load_gem('sqlite3') org.sqlite.JDBC end, :oracle=>proc do |db| require 'sequel_core/adapters/jdbc/oracle' db.extend(Sequel::JDBC::Oracle::DatabaseMethods) Java::oracle.jdbc.driver.OracleDriver end, :sqlserver=>proc do |db| require 'sequel_core/adapters/shared/mssql' db.extend(Sequel::MSSQL::DatabaseMethods) com.microsoft.sqlserver.jdbc.SQLServerDriver end }
Class Method Summary collapse
-
.load_gem(name) ⇒ Object
Allowing loading the necessary JDBC support via a gem, which works for PostgreSQL, MySQL, and SQLite.
Class Method Details
.load_gem(name) ⇒ Object
Allowing loading the necessary JDBC support via a gem, which works for PostgreSQL, MySQL, and SQLite.
69 70 71 72 73 74 75 |
# File 'lib/sequel_core/adapters/jdbc.rb', line 69 def self.load_gem(name) begin require "jdbc/#{name}" rescue LoadError # jdbc gem not used, hopefully the user has the .jar in their CLASSPATH end end |