VTK  9.2.6
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
75#ifndef vtkODBCDatabase_h
76#define vtkODBCDatabase_h
77
78#include "vtkIOODBCModule.h" // For export macro
79#include "vtkSQLDatabase.h"
80
81class vtkSQLQuery;
82class vtkODBCQuery;
83class vtkStringArray;
85
86class VTKIOODBC_EXPORT vtkODBCDatabase : public vtkSQLDatabase
87{
88
89 friend class vtkODBCQuery;
90
91public:
93 void PrintSelf(ostream& os, vtkIndent indent) override;
95
101 bool Open(const char* password) override;
102
106 void Close() override;
107
111 bool IsOpen() override;
112
117
121 const char* GetLastErrorText() override;
122
127
131 vtkStringArray* GetRecord(const char* table) override;
132
136 bool IsSupported(int feature) override;
137
139
144 vtkSetStringMacro(DataSourceName);
145 vtkGetStringMacro(DataSourceName);
147
148 vtkSetMacro(ServerPort, int);
149 vtkSetStringMacro(HostName);
150 vtkSetStringMacro(UserName);
151 vtkSetStringMacro(DatabaseName);
152 vtkGetStringMacro(DatabaseName);
153 vtkSetStringMacro(Password);
154
155 bool HasError() override;
156
158
161 const char* GetDatabaseType() override { return this->DatabaseType; }
163
165
174 vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
175
181 vtkSQLDatabaseSchema* schema, int tblHandle, int idxHandle, bool& skipped) override;
182
187 bool CreateDatabase(const char* dbName, bool dropExisting);
188
193 bool DropDatabase(const char* dbName);
194
200 bool ParseURL(const char* url) override;
201
202protected:
205
206 vtkSetStringMacro(LastErrorText);
207
208private:
209 vtkStringArray* Tables;
210 vtkStringArray* Record;
211
212 char* LastErrorText;
213
214 char* HostName;
215 char* UserName;
216 char* Password;
217 char* DataSourceName;
218 char* DatabaseName;
219 int ServerPort;
220
221 vtkODBCInternals* Internals;
222
223 // We want this to be private, a user of this class
224 // should not be setting this for any reason
225 vtkSetStringMacro(DatabaseType);
226
227 char* DatabaseType;
228
229 vtkODBCDatabase(const vtkODBCDatabase&) = delete;
230 void operator=(const vtkODBCDatabase&) = delete;
231};
232
233#endif // vtkODBCDatabase_h
a simple class to control print indentation
Definition vtkIndent.h:40
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
represent an SQL database schema
maintain a connection to an sql database
executes an sql query and retrieves results
Definition vtkSQLQuery.h:75
Wrapper around std::string to keep symbols short.
a vtkAbstractArray subclass for strings