indexing description: "Objects that provide an interface to access information in the database." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" deferred class DATABASE_ACCESS inherit O_SHARED_LOGGERS EXCEPTIONS O_ERRORS feature {NONE} -- Initialization make (a_db_handler: like db_handler) is -- Initialize. require a_db_handler_ok: a_db_handler /= Void do db_handler := a_db_handler create select_query.make (Current) ensure db_handler_set: db_handler = a_db_handler end feature {DATABASE_QUERY} -- Database access db_handler: DATABASE_HANDLER -- Database handler. handle_errors_and_warnings is -- Check for database errors and warnings and log them. local l_control: DB_CONTROL l_warning: STRING do l_control := db_handler.db_control -- any errors? if not l_control.is_ok then node_logger.fatal ("Database error: "+l_control.error_message) l_control.reset -- reconnect to the db as this may have been a connection lost error l_control.disconnect l_control.connect raise (except_database_error) end l_warning := l_control.warning_message if l_warning /= Void and then not l_warning.is_empty then node_logger.warn ("Database warning: "+l_control.warning_message) end l_control.reset end feature {NONE} -- Implementation helper select_query: DATABASE_SELECT_QUERY -- Query object for select queries. feature -- Select queries last_insert_id: INTEGER is -- Get id of last autoincrement local l_res: SELECTION_RESULT do l_res := select_query.execute_query ("SELECT LAST_INSERT_ID() AS id") l_res.start Result := l_res.read_integer ("id") end invariant db_handler_not_void: db_handler /= Void select_query_not_void: select_query /= Void end