axqt / qtfirebirdibppsqldriver

Automatically exported from code.google.com/p/qtfirebirdibppsqldriver
GNU General Public License v3.0
0 stars 0 forks source link

Add support of firebird ROLE #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
new procedure QFBDriver::open :
bool QFBDriver::open(const QString & db,
                     const QString & user,
                     const QString & password,
                     const QString & host,
                     int /*port*/,
                     const QString & connOpts )
{

    QString charSet = QLatin1String("WIN1251");
    QString role    = QLatin1String("");
    // Set connection attributes
    const QStringList opts(connOpts.split(QLatin1Char(';'),
QString::SkipEmptyParts));
    for (int i = 0; i < opts.count(); ++i)
    {
        const QString tmp(opts.at(i));
        int idx;
        if ((idx = tmp.indexOf(QLatin1Char('='))) == -1)
        {
            qWarning("QFBDriver::open: Illegal connect option value '%s'",
                     tmp.toLocal8Bit().constData());
            continue;
        }

        const QString opt(tmp.left(idx));
        const QString val(tmp.mid(idx + 1).simplified());

        if (opt == QLatin1String("CHARSET"))
        {
            if ((val == QLatin1String("NONE")) || (val ==
QLatin1String("WIN1251")))
            {
                charSet = val;
            }
            else
            {
                qWarning("QFBDriver::open: Unknown option value '%s'",
                         tmp.toLocal8Bit().constData());
                continue;
            }
        }
        if (opt == QLatin1String("ROLE"))
        {
            role = val;
        }
        else
        {
            qWarning("QFBDriver::open: Unknown connection attribute '%s'",
                     tmp.toLocal8Bit().constData());
        }
    }

    if (charSet.isEmpty())
    {
        qWarning("QFBDriver::open: set database charset");
        return false;
    }

    if (isOpen())
        close();

    try
    {
        dp->iDb=IBPP::DatabaseFactory(host.toStdString(),
                                      db.toStdString(),
                                      user.toStdString(),
                                      password.toStdString(),
                                      role.toStdString(),
                                      charSet.toStdString(),"");

        dp->iDb->Connect();

    }
    catch (IBPP::Exception& e)
    {
        setOpenError(TRUE);
        dp->setError("Unable to connect", e, QSqlError::ConnectionError);
        return false;
    }

    setOpen(true);
    return true;
}

Original issue reported on code.google.com by g1099511...@gmail.com on 20 Jan 2010 at 1:51

GoogleCodeExporter commented 9 years ago

Original comment by alex.wen...@gmail.com on 25 Jan 2010 at 12:45

GoogleCodeExporter commented 9 years ago
use QSqlDriver::open(db, user, password, host, port, "ROLE=...")

Original comment by alex.wen...@gmail.com on 25 Jan 2010 at 2:59