zoukankan      html  css  js  c++  java
  • qt 与mysql建立交互式连接

    void QSqlDatabase::setConnectOptions(const QString & options = QString())
    Sets database-specific options. This must be done before the connection is opened or it has no effect (or you can close() the connection, call this function and open() the connection again).

    The format of the options string is a semicolon separated list of option names or option=value pairs. The options depend on the database client used:

    ODBC MySQL PostgreSQL
    SQL_ATTR_ACCESS_MODE
    SQL_ATTR_LOGIN_TIMEOUT
    SQL_ATTR_CONNECTION_TIMEOUT
    SQL_ATTR_CURRENT_CATALOG
    SQL_ATTR_METADATA_ID
    SQL_ATTR_PACKET_SIZE
    SQL_ATTR_TRACEFILE
    SQL_ATTR_TRACE
    SQL_ATTR_CONNECTION_POOLING
    SQL_ATTR_ODBC_VERSION
    CLIENT_COMPRESS
    CLIENT_FOUND_ROWS
    CLIENT_IGNORE_SPACE
    CLIENT_SSL
    CLIENT_ODBC
    CLIENT_NO_SCHEMA
    CLIENT_INTERACTIVE
    UNIX_SOCKET
    MYSQL_OPT_RECONNECT
    connect_timeout
    options
    tty
    requiressl
    service
    DB2 OCI TDS
    SQL_ATTR_ACCESS_MODE
    SQL_ATTR_LOGIN_TIMEOUT
    OCI_ATTR_PREFETCH_ROWS
    OCI_ATTR_PREFETCH_MEMORY
    none
    SQLite Interbase
    QSQLITE_BUSY_TIMEOUT
    QSQLITE_OPEN_READONLY
    QSQLITE_OPEN_URI
    QSQLITE_ENABLE_SHARED_CACHE
    ISC_DPB_LC_CTYPE
    ISC_DPB_SQL_ROLE_NAME
    Examples:

    ...
    // MySQL connection
    db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1"); // use an SSL connection to the server
    if (!db.open()) {
    db.setConnectOptions(); // clears the connect option string
    ...
    }
    ...
    // PostgreSQL connection
    db.setConnectOptions("requiressl=1"); // enable PostgreSQL SSL connections
    if (!db.open()) {
    db.setConnectOptions(); // clear options
    ...
    }
    ...
    // ODBC connection
    db.setConnectOptions("SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY;SQL_ATTR_TRACE=SQL_OPT_TRACE_ON"); // set ODBC options
    if (!db.open()) {
    db.setConnectOptions(); // don't try to set this option
    ...
    }

  • 相关阅读:
    Codevs 2602 最短路径问题
    NOIp2015酱油酱油记
    51Nod-1091 线段的重叠
    poj-3264-Balanced Lineup
    51Nod-1212 无向图最小生成树
    51Nod-1279 扔盘子
    51Nod--1010 只包含235的数
    51Nod--1015 水仙花数
    51Nod-1136 欧拉函数
    使用caffe训练自己的CNN
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/4831445.html
Copyright © 2011-2022 走看看