|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.sql.QSqlDriver
public abstract class QSqlDriver
The QSqlDriver class is an abstract base class for accessing specific SQL databases. This class should not be used directly. Use QSqlDatabase
instead.
If you want to create your own SQL drivers, you can subclass this class and reimplement its pure virtual functions and those virtual functions that you need. See How to Write Your Own Database Driver for more information.
QSqlDatabase
, and QSqlResult
.
Nested Class Summary | |
---|---|
static class |
QSqlDriver.DriverFeature
This enum contains a list of features a driver might support. |
static class |
QSqlDriver.IdentifierType
This enum contains a list of SQL identifier types. |
static class |
QSqlDriver.StatementType
This enum contains a list of SQL statement (or clause) types the driver can create. |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
notification
This signal takes 1 generic argument(s). |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QSqlDriver()
Constructs a new driver with the given parent. |
|
QSqlDriver(QObject parent)
Constructs a new driver with the given parent. |
Method Summary | |
---|---|
boolean |
beginTransaction()
This function is called to begin a transaction. |
abstract void |
close()
Derived classes must reimplement this pure virtual function in order to close the database connection. |
boolean |
commitTransaction()
This function is called to commit a transaction. |
abstract QSqlResult |
createResult()
Creates an empty SQL result on the database. |
java.lang.String |
escapeIdentifier(java.lang.String identifier,
QSqlDriver.IdentifierType type)
Returns the identifier escaped according to the database rules. |
java.lang.String |
formatValue(QSqlField field)
Use the other formatValue() overload instead. |
java.lang.String |
formatValue(QSqlField field,
boolean trimStrings)
Use the other formatValue() overload instead. |
java.lang.Object |
handle()
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no handle. |
abstract boolean |
hasFeature(QSqlDriver.DriverFeature f)
Returns true if the driver supports feature feature; otherwise returns false. |
boolean |
isOpen()
Returns true if the database connection is open; otherwise returns false. |
boolean |
isOpenError()
Returns true if the there was an error opening the database connection; otherwise returns false. |
QSqlError |
lastError()
Returns a QSqlError object which contains information about the last error that occurred on the database. |
boolean |
open(java.lang.String db)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
boolean |
open(java.lang.String db,
java.lang.String user)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
boolean |
open(java.lang.String db,
java.lang.String user,
java.lang.String password)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
boolean |
open(java.lang.String db,
java.lang.String user,
java.lang.String password,
java.lang.String host)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
boolean |
open(java.lang.String db,
java.lang.String user,
java.lang.String password,
java.lang.String host,
int port)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
abstract boolean |
open(java.lang.String db,
java.lang.String user,
java.lang.String password,
java.lang.String host,
int port,
java.lang.String connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. |
QSqlIndex |
primaryIndex(java.lang.String tableName)
Returns the primary index for table tableName. |
QSqlRecord |
record(java.lang.String tableName)
Returns a QSqlRecord populated with the names of the fields in table tableName. |
boolean |
rollbackTransaction()
This function is called to rollback a transaction. |
protected void |
setLastError(QSqlError e)
This function is used to set the value of the last error, error, that occurred on the database. |
protected void |
setOpen(boolean o)
This function sets the open state of the database to open. |
protected void |
setOpenError(boolean e)
This function sets the open error state of the database to error. |
java.lang.String |
sqlStatement(QSqlDriver.StatementType type,
java.lang.String tableName,
QSqlRecord rec,
boolean preparedStatement)
Returns a SQL statement of type type for the table tableName with the values from rec. |
java.util.List |
subscribedToNotifications()
Returns a list of the names of the event notifications that are currently subscribed to. |
protected java.util.List |
subscribedToNotificationsImplementation()
Returns a list of the names of the event notifications that are currently subscribed to. |
boolean |
subscribeToNotification(java.lang.String name)
This function is called to subscribe to event notifications from the database. |
protected boolean |
subscribeToNotificationImplementation(java.lang.String name)
This slot is called to subscribe to event notifications from the database. |
java.util.List |
tables(QSql.TableType tableType)
Returns a list of the names of the tables in the database. |
boolean |
unsubscribeFromNotification(java.lang.String name)
This function is called to unsubscribe from event notifications from the database. |
protected boolean |
unsubscribeFromNotificationImplementation(java.lang.String name)
This slot is called to unsubscribe from event notifications from the database. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 notification
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: name)>:
This signal is emitted when the database posts an event notification that the driver subscribes to. name identifies the event notification.
subscribeToNotification()
.
Constructor Detail |
---|
public QSqlDriver()
public QSqlDriver(QObject parent)
Method Detail |
---|
public final boolean isOpenError()
public final QSqlError lastError()
QSqlError
object which contains information about the last error that occurred on the database. setLastError()
.
public final boolean subscribeToNotification(java.lang.String name)
If successful, return true, otherwise return false.
The database must be open when this function is called. When the database is closed by calling close()
all subscribed event notifications are automatically unsubscribed. Note that calling open()
on an already open database may implicitly cause close()
to be called, which will cause the driver to unsubscribe from all event notifications.
When an event notification identified by name is posted by the database the notification()
signal is emitted.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide event notification support in your own QSqlDriver subclass, reimplement the subscribeToNotificationImplementation()
slot in your subclass instead. The subscribeToNotification()
function will dynamically detect the slot and call it.
unsubscribeFromNotification()
, subscribedToNotifications()
, and QSqlDriver::hasFeature()
.
protected final boolean subscribeToNotificationImplementation(java.lang.String name)
If successful, return true, otherwise return false.
The database must be open when this slot is called. When the database is closed by calling close()
all subscribed event notifications are automatically unsubscribed. Note that calling open()
on an already open database may implicitly cause close()
to be called, which will cause the driver to unsubscribe from all event notifications.
When an event notification identified by name is posted by the database the notification()
signal is emitted.
Reimplement this slot to provide your own QSqlDriver subclass with event notification support; because of binary compatibility constraints, the subscribeToNotification()
function (introduced in Qt 4.4) is not virtual. Instead, subscribeToNotification()
will dynamically detect and call this slot. The default implementation does nothing and returns false.
subscribeToNotification()
.
public final java.util.List subscribedToNotifications()
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide event notification support in your own QSqlDriver subclass, reimplement the subscribedToNotificationsImplementation()
slot in your subclass instead. The subscribedToNotifications()
function will dynamically detect the slot and call it.
subscribeToNotification()
, and unsubscribeFromNotification()
.
protected final java.util.List subscribedToNotificationsImplementation()
Reimplement this slot to provide your own QSqlDriver subclass with event notification support; because of binary compatibility constraints, the subscribedToNotifications()
function (introduced in Qt 4.4) is not virtual. Instead, subscribedToNotifications()
will dynamically detect and call this slot. The default implementation simply returns an empty QStringList.
subscribedToNotifications()
.
public final boolean unsubscribeFromNotification(java.lang.String name)
If successful, return true, otherwise return false.
The database must be open when this function is called. All subscribed event notifications are automatically unsubscribed from when the close()
function is called.
After calling this function the notification()
signal will no longer be emitted when an event notification identified by name is posted by the database.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide event notification support in your own QSqlDriver subclass, reimplement the unsubscribeFromNotificationImplementation()
slot in your subclass instead. The unsubscribeFromNotification()
function will dynamically detect the slot and call it.
subscribeToNotification()
, and subscribedToNotifications()
.
protected final boolean unsubscribeFromNotificationImplementation(java.lang.String name)
If successful, return true, otherwise return false.
The database must be open when this slot is called. All subscribed event notifications are automatically unsubscribed from when the close()
function is called.
After calling this slot the notification()
signal will no longer be emitted when an event notification identified by name is posted by the database.
Reimplement this slot to provide your own QSqlDriver subclass with event notification support; because of binary compatibility constraints, the unsubscribeFromNotification()
function (introduced in Qt 4.4) is not virtual. Instead, unsubscribeFromNotification()
will dynamically detect and call this slot. The default implementation does nothing and returns false.
unsubscribeFromNotification()
.
public boolean beginTransaction()
commitTransaction()
, and rollbackTransaction()
.
public abstract void close()
open()
, and setOpen()
.
public boolean commitTransaction()
beginTransaction()
, and rollbackTransaction()
.
public abstract QSqlResult createResult()
QSqlResult
object appropriate for their database to the caller.
public java.lang.String escapeIdentifier(java.lang.String identifier, QSqlDriver.IdentifierType type)
The default implementation does nothing.
public final java.lang.String formatValue(QSqlField field)
formatValue()
overload instead.
public java.lang.String formatValue(QSqlField field, boolean trimStrings)
formatValue()
overload instead.
public java.lang.Object handle()
QVariant
or an invalid variant if there is no handle. Warning: Use this with uttermost care and only if you know what you're doing.
Warning: The handle returned here can become a stale pointer if the connection is modified (for example, if you close the connection).
Warning: The handle can be NULL if the connection is not open yet.
The handle returned here is database-dependent, you should query the type name of the variant before accessing it.
This example retrieves the handle for a connection to sqlite:
QSqlDatabase db = QSqlDatabase.addDatabase("QPSQL"); QVariant v = db.driver().handle(); if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")) { // v.data() returns a pointer to the handle sqlite3 handle = static_cast<sqlite3 **>(v.data()); if (handle != 0) { // check that it is not NULL ;// ... } }This snippet returns the handle for PostgreSQL or MySQL:
if (v.typeName() == "PGconn*") { PGconn handle = tatic_cast<PGconn **>(v.data()); if (handle != 0) ; // ... } if (v.typeName() == "MYSQL*") { MYSQL handle = static_cast<MYSQL **>(v.data()); if (handle != 0) ; // ... }
QSqlResult::handle()
.
public abstract boolean hasFeature(QSqlDriver.DriverFeature f)
Note that some databases need to be open()
before this can be determined.
DriverFeature
.
public boolean isOpen()
public final boolean open(java.lang.String db, java.lang.String user, java.lang.String password, java.lang.String host, int port)
The function must return true on success and false on failure.
setOpen()
.
public final boolean open(java.lang.String db, java.lang.String user, java.lang.String password, java.lang.String host)
The function must return true on success and false on failure.
setOpen()
.
public final boolean open(java.lang.String db, java.lang.String user, java.lang.String password)
The function must return true on success and false on failure.
setOpen()
.
public final boolean open(java.lang.String db, java.lang.String user)
The function must return true on success and false on failure.
setOpen()
.
public final boolean open(java.lang.String db)
The function must return true on success and false on failure.
setOpen()
.
public abstract boolean open(java.lang.String db, java.lang.String user, java.lang.String password, java.lang.String host, int port, java.lang.String connOpts)
The function must return true on success and false on failure.
setOpen()
.
public QSqlIndex primaryIndex(java.lang.String tableName)
QSqlIndex
if the table doesn't have a primary index. The default implementation returns an empty index.
public QSqlRecord record(java.lang.String tableName)
QSqlRecord
populated with the names of the fields in table tableName. If no such table exists, an empty record is returned. The default implementation returns an empty record.
public boolean rollbackTransaction()
beginTransaction()
, and commitTransaction()
.
protected void setLastError(QSqlError e)
lastError()
.
protected void setOpen(boolean o)
open()
. open()
, and setOpenError()
.
protected void setOpenError(boolean e)
open()
. Note that if error is true the open state of the database is set to closed (i.e., isOpen()
returns false). isOpenError()
, open()
, and setOpen()
.
public java.lang.String sqlStatement(QSqlDriver.StatementType type, java.lang.String tableName, QSqlRecord rec, boolean preparedStatement)
This method can be used to manipulate tables without having to worry about database-dependent SQL dialects. For non-prepared statements, the values will be properly escaped.
public java.util.List tables(QSql.TableType tableType)
The tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as QSql::Tables
for backward compatibility.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |