2
** File: evisdatabaseconnection.h
3
** Author: Peter J. Ersts ( ersts at amnh.org )
4
** Creation Date: 2007-03-07
6
** Copyright ( c ) 2007, American Museum of Natural History. All rights reserved.
8
** This library/program is free software; you can redistribute it
9
** and/or modify it under the terms of the GNU Library General Public
10
** License as published by the Free Software Foundation; either
11
** version 2 of the License, or ( at your option ) any later version.
13
** This library/program is distributed in the hope that it will be useful,
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
** Library General Public License for more details.
18
** This work was made possible through a grant by the the John D. and
19
** Catherine T. MacArthur Foundation. Additionally, this program was prepared by
20
** the American Museum of Natural History under award No. NA05SEC46391002
21
** from the National Oceanic and Atmospheric Administration, U.S. Department
22
** of Commerce. The statements, findings, conclusions, and recommendations
23
** are those of the author( s ) and do not necessarily reflect the views of the
24
** National Oceanic and Atmospheric Administration or the Department of Commerce.
28
#ifndef EVISDATABASECONNECTION_H
29
#define EVISDATABASECONNECTION_H
31
#include "evisquerydefinition.h"
33
#include <QStringList>
34
#include <QtSql/QSqlDatabase>
35
#include <QtSql/QSqlQuery>
36
#include <QtSql/QSqlError>
39
* \class eVisDatabaseConnection
40
* \brief A class that provides the ability to connect to a variety of database types
41
* This class provides the ability to connect to a variety of database types
43
class eVisDatabaseConnection
48
/** \brief Enum containting the type of database supported by this class */
59
/** \brief Constructor */
60
eVisDatabaseConnection( QString, int, QString, QString, QString, DATABASE_TYPE );
62
/** \brief Public method that finalizes a connection to a databse */
65
/** \brief Public method that passes an SQL statement to the database for execution */
66
QSqlQuery* query( QString );
68
/** \brief Public method for resetting the database connection parameters - equivalent to re running the constructor */
69
void resetConnectionParameters( QString, int, QString, QString, QString, DATABASE_TYPE );
71
/** \brief Returns a list of tables in the current database */
72
QStringList tables( );
74
/** \brief Accessor to the database type */
75
DATABASE_TYPE databaseType( )
80
/** \brief Public method for closing the current database connection */
86
/** \brief Public method for requesting the last error reported by the database connect or query */
92
/** \brief Mutator for database type */
93
void setDatabaseType( DATABASE_TYPE connectionType )
95
mDatabaseType = connectionType;
99
/** \brief Variable used to store the query results */
103
/** \brief Host name for the database server */
106
/** \brief Port number the database server is listenting to */
109
/** \brief Database name, can also be a filename in the case of SQLite or MSAccess */
110
QString mDatabaseName;
112
/** \brief Username for accessing the database */
115
/** \brief Password associated with the username for accessing the database */
118
/** \brief QString containing the last reported error message */
121
/** \brief The database object */
122
QSqlDatabase mDatabase;
124
/** \brief Sets the error messages */
125
void setLastError( QString error )