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
    ...
    }

  • 相关阅读:
    火狐URL编码问题
    Asp.net动态关键字
    charindex ,PATINDEX,contains,FREETEXT用法
    PanGu词库批量添加关键词
    Dictionary SortedList HashSet List用法
    hubbledotnet查询速度慢的问题
    asp.net 页面static变量问题
    String.Concat和String.Format用法
    .net显示今天农历的代码
    存储过程用户登录
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/4831445.html
Copyright © 2011-2022 走看看