VTK  9.1.0
vtkODBCDatabase.h
Go to the documentation of this file.
1/* -*- Mode: C++; -*- */
2
3/*=========================================================================
4
5 Program: Visualization Toolkit
6 Module: vtkODBCDatabase.h
7
8 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
9 All rights reserved.
10 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
11
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notice for more information.
15
16=========================================================================*/
17/*-------------------------------------------------------------------------
18 Copyright 2008 Sandia Corporation.
19 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
20 the U.S. Government retains certain rights in this software.
21-------------------------------------------------------------------------*/
22
72#ifndef vtkODBCDatabase_h
73#define vtkODBCDatabase_h
74
75#include "vtkIOODBCModule.h" // For export macro
76#include "vtkSQLDatabase.h"
77
78class vtkSQLQuery;
79class vtkODBCQuery;
80class vtkStringArray;
82
83class VTKIOODBC_EXPORT vtkODBCDatabase : public vtkSQLDatabase
84{
85
86 friend class vtkODBCQuery;
87
88public:
90 void PrintSelf(ostream& os, vtkIndent indent) override;
92
98 bool Open(const char* password) override;
99
103 void Close() override;
104
108 bool IsOpen() override;
109
114
118 const char* GetLastErrorText() override;
119
124
128 vtkStringArray* GetRecord(const char* table) override;
129
133 bool IsSupported(int feature) override;
134
136
141 vtkSetStringMacro(DataSourceName);
142 vtkGetStringMacro(DataSourceName);
144
145 vtkSetMacro(ServerPort, int);
146 vtkSetStringMacro(HostName);
147 vtkSetStringMacro(UserName);
148 vtkSetStringMacro(DatabaseName);
149 vtkGetStringMacro(DatabaseName);
150 vtkSetStringMacro(Password);
151
152 bool HasError() override;
153
155
158 const char* GetDatabaseType() override { return this->DatabaseType; }
160
162
171 vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
172
178 vtkSQLDatabaseSchema* schema, int tblHandle, int idxHandle, bool& skipped) override;
179
184 bool CreateDatabase(const char* dbName, bool dropExisting);
185
190 bool DropDatabase(const char* dbName);
191
197 bool ParseURL(const char* url) override;
198
199protected:
202
203 vtkSetStringMacro(LastErrorText);
204
205private:
206 vtkStringArray* Tables;
207 vtkStringArray* Record;
208
209 char* LastErrorText;
210
211 char* HostName;
212 char* UserName;
213 char* Password;
214 char* DataSourceName;
215 char* DatabaseName;
216 int ServerPort;
217
218 vtkODBCInternals* Internals;
219
220 // We want this to be private, a user of this class
221 // should not be setting this for any reason
222 vtkSetStringMacro(DatabaseType);
223
224 char* DatabaseType;
225
226 vtkODBCDatabase(const vtkODBCDatabase&) = delete;
227 void operator=(const vtkODBCDatabase&) = delete;
228};
229
230#endif // vtkODBCDatabase_h
a simple class to control print indentation
Definition: vtkIndent.h:113
maintain an ODBC connection to a SQL database
vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle) override
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement.
bool DropDatabase(const char *dbName)
Drop a database if it exists.
const char * GetLastErrorText() override
Get the last error text from the database.
vtkStringArray * GetRecord(const char *table) override
Get the list of fields for a particular table.
vtkStringArray * GetTables() override
Get the list of tables from the database.
vtkSQLQuery * GetQueryInstance() override
Return an empty query on this database.
bool HasError() override
Did the last operation generate an error.
vtkStdString GetURL() override
Get the URL of the database.
bool Open(const char *password) override
Open a new connection to the database.
const char * GetDatabaseType() override
String representing database type (e.g.
bool CreateDatabase(const char *dbName, bool dropExisting)
Create a new database, optionally dropping any existing database of the same name.
~vtkODBCDatabase() override
bool IsSupported(int feature) override
Return whether a feature is supported by the database.
bool ParseURL(const char *url) override
This will only handle URLs of the form odbc://[user@]datsourcename[:port]/[dbname].
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Close() override
Close the connection to the database.
bool IsOpen() override
Return whether the database has an open connection.
vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped) override
Return the SQL string with the syntax to create an index inside a "CREATE TABLE" SQL statement.
static vtkODBCDatabase * New()
Simple class to hide ODBC structures.
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:49
represent an SQL database schema
maintain a connection to an sql database
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:69
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
a vtkAbstractArray subclass for strings