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).
Classes and Modules
Module Sequel::JDBC::H2Module Sequel::JDBC::JavaLang
Module Sequel::JDBC::JavaSQL
Module Sequel::JDBC::MySQL
Module Sequel::JDBC::Oracle
Module Sequel::JDBC::Postgres
Module Sequel::JDBC::SQLite
Class Sequel::JDBC::Database
Class Sequel::JDBC::Dataset
Constants
| DATABASE_SETUP | = | {: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, :h2=>proc do |db| require 'sequel_core/adapters/jdbc/h2' db.extend(Sequel::JDBC::H2::DatabaseMethods) JDBC.load_gem('h2') org.h2.Driver end } | Contains procs keyed on sub adapter type that extend the given database object so it supports the correct database type. |
Public class methods
Allowing loading the necessary JDBC support via a gem, which works for PostgreSQL, MySQL, and SQLite.
# File lib/sequel_core/adapters/jdbc.rb, line 75 75: def self.load_gem(name) 76: begin 77: require "jdbc/#{name}" 78: rescue LoadError 79: # jdbc gem not used, hopefully the user has the .jar in their CLASSPATH 80: end 81: end