MySQL exception handling with SQLState is less accurate than with regexps.
# File lib/sequel/adapters/jdbc/mysql.rb, line 25 def database_exception_use_sqlstates? false end
The database name for the given database. Need to parse it out of the connection string, since the JDBC does no parsing on the given connection string by default.
# File lib/sequel/adapters/jdbc/mysql.rb, line 19 def database_name u = URI.parse(uri.sub(/\Ajdbc:/, '')) (m = /\/(.*)/.match(u.path)) && m[1] end
Get the last inserted id using LAST_INSERT_ID().
# File lib/sequel/adapters/jdbc/mysql.rb, line 30 def last_insert_id(conn, opts=OPTS) if stmt = opts[:stmt] rs = stmt.getGeneratedKeys begin if rs.next rs.getInt(1) else 0 end ensure rs.close end else statement(conn) do |stmt| rs = stmt.executeQuery(LAST_INSERT_ID) rs.next rs.getInt(1) end end end
Return generated keys for insert statements.
# File lib/sequel/adapters/jdbc/mysql.rb, line 58 def prepare_jdbc_statement(conn, sql, opts) opts[:type] == :insert ? conn.prepareStatement(sql, JavaSQL::Statement.RETURN_GENERATED_KEYS) : super end
Convert tinyint(1) type to boolean
# File lib/sequel/adapters/jdbc/mysql.rb, line 63 def schema_column_type(db_type) db_type =~ /\Atinyint\(1\)/ ? :boolean : super end
Run the default connection setting SQL statements. Apply the connectiong setting SQLs for every new connection.
# File lib/sequel/adapters/jdbc/mysql.rb, line 69 def setup_connection(conn) mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_yield(sql){s.execute(sql)}}} super end