module Sequel::JDBC::MySQL::DatabaseMethods
Private Instance Methods
database_exception_use_sqlstates?()
click to toggle source
MySQL
exception handling with SQLState is less accurate than with regexps.
# File lib/sequel/adapters/jdbc/mysql.rb 23 def database_exception_use_sqlstates? 24 false 25 end
disconnect_error?(exception, opts)
click to toggle source
Raise a disconnect error if the SQL
state of the cause of the exception indicates so.
Calls superclass method
# File lib/sequel/adapters/jdbc/mysql.rb 28 def disconnect_error?(exception, opts) 29 exception.message =~ /\ACommunications link failure/ || super 30 end
execute_statement_insert(stmt, sql)
click to toggle source
last_insert_id(conn, opts=OPTS)
click to toggle source
Get the last inserted id using LAST_INSERT_ID().
# File lib/sequel/adapters/jdbc/mysql.rb 33 def last_insert_id(conn, opts=OPTS) 34 if stmt = opts[:stmt] 35 rs = stmt.getGeneratedKeys 36 begin 37 if rs.next 38 rs.getLong(1) 39 else 40 0 41 end 42 ensure 43 rs.close 44 end 45 else 46 statement(conn) do |st| 47 rs = st.executeQuery('SELECT LAST_INSERT_ID()') 48 rs.next 49 rs.getLong(1) 50 end 51 end 52 end
prepare_jdbc_statement(conn, sql, opts)
click to toggle source
Return generated keys for insert statements.
Calls superclass method
# File lib/sequel/adapters/jdbc/mysql.rb 61 def prepare_jdbc_statement(conn, sql, opts) 62 opts[:type] == :insert ? conn.prepareStatement(sql, JavaSQL::Statement::RETURN_GENERATED_KEYS) : super 63 end
schema_column_type(db_type)
click to toggle source
Convert tinyint(1) type to boolean
Calls superclass method
Sequel::MySQL::DatabaseMethods#schema_column_type
# File lib/sequel/adapters/jdbc/mysql.rb 66 def schema_column_type(db_type) 67 db_type =~ /\Atinyint\(1\)/ ? :boolean : super 68 end
setup_connection(conn)
click to toggle source
Run the default connection setting SQL
statements. Apply the connectiong setting SQLs for every new connection.
Calls superclass method
# File lib/sequel/adapters/jdbc/mysql.rb 72 def setup_connection(conn) 73 mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_connection_yield(sql, conn){s.execute(sql)}}} 74 super 75 end
setup_type_convertor_map()
click to toggle source
Handle unsigned integer values
Calls superclass method
# File lib/sequel/adapters/jdbc/mysql.rb 78 def setup_type_convertor_map 79 super 80 TypeConvertor::BASIC_MAP.dup 81 @type_convertor_map[Java::JavaSQL::Types::SMALLINT] = @type_convertor_map[Java::JavaSQL::Types::INTEGER] 82 @type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT] 83 @basic_type_convertor_map[Java::JavaSQL::Types::SMALLINT] = @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] 84 @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] = @basic_type_convertor_map[Java::JavaSQL::Types::BIGINT] 85 end