Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SLPluginFeature::DBAccess Class Reference
[Plugins system]

This abstract class is the interface for Database Access. More...

#include <SLPluginFeature.hpp>

Inheritance diagram for SLPluginFeature::DBAccess:

Inheritance graph
[legend]
Collaboration diagram for SLPluginFeature::DBAccess:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual SLPluginFeature::DBAccess::ConnectiongetConnection (const char *dbName="segusoland")=0

Detailed Description

This abstract class is the interface for Database Access.

See also:
SLPluginFeature
Author:
Alexandre Sauve
It is mainly designed to get connections from database.

example of usage :

#include <iostream> #include "segusoland.hpp" #include "SLPluginRegister.hpp" #include "SLPluginFeature.hpp" try { // get DB Feature (quick) SLPluginFeature::DBAccess *db = SL_FEATURE_GET(DBAccess); // real connection to the database (speed may vary) SLPluginFeature::DBAccess::Connection &con = db->getConnection(NULL); // get the results of a SQL request SLPluginFeature::DBAccess::Results *results = con.execSQL("select * from files limit 10"); // go through the results // database columns values are all in "char *" format while (results->next()) { for (unsigned int i = 0; i < results->getRowCount(); i++) { const char *str = results->getColumn(i); // print the column content std::cout << "| " << ((str == NULL) ? "NULL" : str); } std::cout << std::endl; } // mandatory : free results set con.freeResults(results); // dispose DB Feature (quick) SL_FEATURE_DISPOSE(db); } catch (SLPluginFeature::DBAccess::Exception &e) { SL_WARNING("GOT AN EXCEPTION : " << e.getMessage().to_utf8()); } catch (SLPluginRegister::NotFoundException &e) { SL_WARNING("COULD NOT FIND THE DBAccess FEATURE : " << e.getMessage().to_utf8()); }


Member Function Documentation

virtual SLPluginFeature::DBAccess::Connection& SLPluginFeature::DBAccess::getConnection const char *  dbName = "segusoland"  )  [pure virtual]
 

Returns an open connection on the database. The connection is taken from a pool and is already connected to the database.

Parameters:
dbName is optionnal and is the database name (should come from SLConfig). If dbName is NULL, then the default db name is choosen.
Exceptions:
SLPluginFeature::DBAccess::Exception in case of db connection failure


The documentation for this class was generated from the following file:
Generated on Mon Apr 19 01:03:38 2004 for segusoLand by doxygen 1.3.6-20040222