Wt  4.11.1
Public Member Functions | List of all members
Wt::Dbo::backend::MSSQLServer Class Reference

A Microsoft SQL Server connection. More...

Inheritance diagram for Wt::Dbo::backend::MSSQLServer:
[legend]

Public Member Functions

 MSSQLServer ()
 Creates a new Microsoft SQL Server backend connection. More...
 
 MSSQLServer (const std::string &connectionString)
 Creates a new Microsoft SQL Server backend connection. More...
 
 MSSQLServer (const MSSQLServer &other)
 Copy constructor. More...
 
virtual ~MSSQLServer ()
 Destructor. More...
 
virtual std::unique_ptr< Wt::Dbo::SqlConnectionclone () const override
 Clones the connection. More...
 
bool connect (const std::string &connectionString)
 Tries to connect. More...
 
virtual void executeSql (const std::string &sql) override
 Executes an SQL statement. More...
 
virtual void startTransaction () override
 Starts a transaction. More...
 
virtual void commitTransaction () override
 Commits a transaction. More...
 
virtual void rollbackTransaction () override
 Rolls back a transaction. More...
 
virtual std::unique_ptr< SqlStatementprepareStatement (const std::string &sql) override
 Prepares a statement. More...
 
Methods that return dialect information
virtual std::string autoincrementSql () const override
 Returns the 'autoincrement' SQL type modifier. More...
 
virtual std::vector< std::string > autoincrementCreateSequenceSql (const std::string &table, const std::string &id) const override
 Returns the SQL statement(s) required to create an id sequence. More...
 
virtual std::vector< std::string > autoincrementDropSequenceSql (const std::string &table, const std::string &id) const override
 Returns the SQL statement(s) required to drop an id sequence. More...
 
virtual std::string autoincrementType () const override
 Returns the 'autoincrement' SQL type. More...
 
virtual std::string autoincrementInsertInfix (const std::string &id) const override
 Returns the infix for an 'autoincrement' insert statement. More...
 
virtual std::string autoincrementInsertSuffix (const std::string &id) const override
 Returns the suffix for an 'autoincrement' insert statement. More...
 
virtual const char * dateTimeType (SqlDateTimeType type) const override
 Returns the date/time type. More...
 
virtual const char * blobType () const override
 Returns the blob type. More...
 
virtual bool requireSubqueryAlias () const override
 Returns the true if the database require subquery alias. More...
 
virtual const char * booleanType () const override
 Returns the boolean type. More...
 
virtual bool supportAlterTable () const override
 Returns true if the backend support Alter Table. More...
 
virtual std::string textType (int size) const override
 Returns the text type. More...
 
virtual LimitQuery limitQueryMethod () const override
 
- Public Member Functions inherited from Wt::Dbo::SqlConnection
virtual ~SqlConnection ()
 Destructor.
 
virtual void executeSqlStateful (const std::string &sql)
 Executes a connection-stateful SQL statement. More...
 
virtual SqlStatementgetStatement (const std::string &id) const
 Returns the statement with the given id. More...
 
virtual void saveStatement (const std::string &id, std::unique_ptr< SqlStatement > statement)
 Saves a statement with the given id. More...
 
void setProperty (const std::string &name, const std::string &value)
 Sets a property. More...
 
std::string property (const std::string &name) const
 Returns a property. More...
 
virtual void prepareForDropTables ()
 Execute code before dropping the tables. More...
 
virtual std::string longLongType () const
 Returns the 64-bit integer type. More...
 
virtual bool supportUpdateCascade () const
 Returns true if the database supports Update Cascade. More...
 
virtual bool usesRowsFromTo () const
 Returns whether the SQL dialect uses 'ROWS ? TO ?', limit or rownum for partial select results. More...
 
virtual bool supportDeferrableFKConstraint () const
 Returns true if the backend supports "deferrable initially deferred" foreign key constraints. More...
 
virtual const char * alterTableConstraintString () const
 Returns the command used in alter table .. drop constraint .. More...
 

Detailed Description

A Microsoft SQL Server connection.

This class provides the backend implementation for Microsoft SQL Server databases.

Constructor & Destructor Documentation

◆ MSSQLServer() [1/3]

Wt::Dbo::backend::MSSQLServer::MSSQLServer ( )

Creates a new Microsoft SQL Server backend connection.

The connection is not yet open, and requires a connect() before it can be used.

◆ MSSQLServer() [2/3]

Wt::Dbo::backend::MSSQLServer::MSSQLServer ( const std::string &  connectionString)

Creates a new Microsoft SQL Server backend connection.

For info about the connection string, see the connect() method.

See also
connect()

◆ MSSQLServer() [3/3]

Wt::Dbo::backend::MSSQLServer::MSSQLServer ( const MSSQLServer other)

Copy constructor.

This creates a new backend connection with the same settings as another connection.

See also
clone()

◆ ~MSSQLServer()

Wt::Dbo::backend::MSSQLServer::~MSSQLServer ( )
virtual

Destructor.

Closes the connection.

Member Function Documentation

◆ autoincrementCreateSequenceSql()

std::vector< std::string > Wt::Dbo::backend::MSSQLServer::autoincrementCreateSequenceSql ( const std::string &  table,
const std::string &  id 
) const
overridevirtual

Returns the SQL statement(s) required to create an id sequence.

This is used by Session::createTables() to create the id sequence for a table. The table's name and primary key are passed as arguments to this function and can be used to construct an SQL sequence that is unique for the table.

Implements Wt::Dbo::SqlConnection.

◆ autoincrementDropSequenceSql()

std::vector< std::string > Wt::Dbo::backend::MSSQLServer::autoincrementDropSequenceSql ( const std::string &  table,
const std::string &  id 
) const
overridevirtual

Returns the SQL statement(s) required to drop an id sequence.

This is used by Session::dropTables() to drop the id sequence for a table. The table's name and primary key are passed as arguments to this function and can be used to construct an SQL sequence that is unique for the table.

Implements Wt::Dbo::SqlConnection.

◆ autoincrementInsertInfix()

std::string Wt::Dbo::backend::MSSQLServer::autoincrementInsertInfix ( const std::string &  id) const
overridevirtual

Returns the infix for an 'autoincrement' insert statement.

This is inserted before the values part of the insert statement, since Microsoft SQL Server requires that the autoincrement id is returned with OUTPUT.

Returns an empty string by default.

Reimplemented from Wt::Dbo::SqlConnection.

◆ autoincrementInsertSuffix()

std::string Wt::Dbo::backend::MSSQLServer::autoincrementInsertSuffix ( const std::string &  id) const
overridevirtual

Returns the suffix for an 'autoincrement' insert statement.

This is appended to the insert statement, since some back-ends need to be indicated that they should return the autoincrement id.

Implements Wt::Dbo::SqlConnection.

◆ autoincrementSql()

std::string Wt::Dbo::backend::MSSQLServer::autoincrementSql ( ) const
overridevirtual

Returns the 'autoincrement' SQL type modifier.

This is used by Session::createTables() to create the id column.

Implements Wt::Dbo::SqlConnection.

◆ autoincrementType()

std::string Wt::Dbo::backend::MSSQLServer::autoincrementType ( ) const
overridevirtual

Returns the 'autoincrement' SQL type.

This is used by Session::createTables() to create the id column.

Implements Wt::Dbo::SqlConnection.

◆ blobType()

const char * Wt::Dbo::backend::MSSQLServer::blobType ( ) const
overridevirtual

◆ booleanType()

const char * Wt::Dbo::backend::MSSQLServer::booleanType ( ) const
overridevirtual

Returns the boolean type.

This method will return "boolean" by default.

Reimplemented from Wt::Dbo::SqlConnection.

◆ clone()

std::unique_ptr< SqlConnection > Wt::Dbo::backend::MSSQLServer::clone ( ) const
overridevirtual

Clones the connection.

Returns a new connection object that is configured like this object. This is used by connection pool implementations to create its connections.

Implements Wt::Dbo::SqlConnection.

◆ commitTransaction()

void Wt::Dbo::backend::MSSQLServer::commitTransaction ( )
overridevirtual

Commits a transaction.

This function commits a transaction.

Implements Wt::Dbo::SqlConnection.

◆ connect()

bool Wt::Dbo::backend::MSSQLServer::connect ( const std::string &  connectionString)

Tries to connect.

Throws an exception if there was a problem, otherwise returns true.

The connection string is the connection string that should be passed to SQLDriverConnectW to connect to the Microsoft SQL Server database.

The connectionString should be UTF-8 encoded.

Example connection string:

Driver={ODBC Driver 13 for SQL Server};
Server=localhost;
UID=SA;
PWD={example password};
Database=example_db;

You could also specify a DSN (Data Source Name) if you have it configured.

See the SQLDriverConnect function documentation on MSDN for more info.

◆ dateTimeType()

const char * Wt::Dbo::backend::MSSQLServer::dateTimeType ( SqlDateTimeType  type) const
overridevirtual

◆ executeSql()

void Wt::Dbo::backend::MSSQLServer::executeSql ( const std::string &  sql)
overridevirtual

Executes an SQL statement.

This is a convenience method for preparing a statement, executing it, and deleting it.

Reimplemented from Wt::Dbo::SqlConnection.

◆ prepareStatement()

std::unique_ptr< SqlStatement > Wt::Dbo::backend::MSSQLServer::prepareStatement ( const std::string &  sql)
overridevirtual

Prepares a statement.

Returns the prepared statement.

Implements Wt::Dbo::SqlConnection.

◆ requireSubqueryAlias()

bool Wt::Dbo::backend::MSSQLServer::requireSubqueryAlias ( ) const
overridevirtual

Returns the true if the database require subquery alias.

This method will return false by default.

Reimplemented from Wt::Dbo::SqlConnection.

◆ rollbackTransaction()

void Wt::Dbo::backend::MSSQLServer::rollbackTransaction ( )
overridevirtual

Rolls back a transaction.

This function rolls back a transaction.

Implements Wt::Dbo::SqlConnection.

◆ startTransaction()

void Wt::Dbo::backend::MSSQLServer::startTransaction ( )
overridevirtual

Starts a transaction.

This function starts a transaction.

Implements Wt::Dbo::SqlConnection.

◆ supportAlterTable()

bool Wt::Dbo::backend::MSSQLServer::supportAlterTable ( ) const
overridevirtual

Returns true if the backend support Alter Table.

This method will return false by default.

Reimplemented from Wt::Dbo::SqlConnection.

◆ textType()

std::string Wt::Dbo::backend::MSSQLServer::textType ( int  size) const
overridevirtual

Returns the text type.

This is the text type for a string. If size = -1, then a type should be returned which does not require size information, otherwise a type should be returned that limits the size of the stored string to size.

This method will return "text" by default if size = -1, and "varchar(size)" otherwise.

See also
SqlStatement::bind(int column, const std::string& value)

Reimplemented from Wt::Dbo::SqlConnection.