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, line 23 def database_exception_use_sqlstates? false 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, line 28 def disconnect_error?(exception, opts) exception.message =~ /\ACommunications link failure/ || super 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, line 33 def last_insert_id(conn, opts=OPTS) if stmt = opts[:stmt] rs = stmt.getGeneratedKeys begin if rs.next rs.getLong(1) else 0 end ensure rs.close end else statement(conn) do |st| rs = st.executeQuery('SELECT LAST_INSERT_ID()') rs.next rs.getLong(1) end end 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, line 61 def prepare_jdbc_statement(conn, sql, opts) opts[:type] == :insert ? conn.prepareStatement(sql, JavaSQL::Statement.RETURN_GENERATED_KEYS) : super 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, line 66 def schema_column_type(db_type) db_type =~ /\Atinyint\(1\)/ ? :boolean : super 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, line 72 def setup_connection(conn) mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_connection_yield(sql, conn){s.execute(sql)}}} super end
setup_type_convertor_map()
click to toggle source
Handle unsigned integer values
Calls superclass method
# File lib/sequel/adapters/jdbc/mysql.rb, line 78 def setup_type_convertor_map super TypeConvertor::BASIC_MAP.dup @type_convertor_map[Java::JavaSQL::Types::SMALLINT] = @type_convertor_map[Java::JavaSQL::Types::INTEGER] @type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT] @basic_type_convertor_map[Java::JavaSQL::Types::SMALLINT] = @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] = @basic_type_convertor_map[Java::JavaSQL::Types::BIGINT] end