30 #include <QStringList>
37 QString Database::_actualConnectionName =
"";
67 _name = _actualConnectionName;
68 if((dbConn ==
Connect) && isValid()) {
70 QString mess =
"Failed to open database default database [" +
_name;
90 _name = _actualConnectionName;
91 if((dbConn ==
Connect) && isValid()) {
93 QString mess =
"Failed to open database specified as " +
_name;
118 QSqlDatabase(init(connName, driverType)), _name(connName) {
119 _name = _actualConnectionName;
139 _name(profile.Name()) {
140 _name = _actualConnectionName;
141 if((dbConn ==
Connect) && isValid()) {
143 QString mess =
"Failed to open database with profile " +
_name;
357 const QString &driverType) {
359 _actualConnectionName = connName;
365 if(connName.isEmpty() && driverType.isEmpty()) {
367 _actualConnectionName = factory->
getDefault();
368 return (factory->
create(_actualConnectionName));
379 if((!connName.isEmpty()) && (driverType.isEmpty())) {
381 _actualConnectionName = connName;
382 return (factory->
create(connName));
393 return (factory->
create(driverType, connName));
419 mess <<
"Database/profile [" << profile.
Name() <<
"] is not valid!" << ends;
423 _actualConnectionName = profile.
Name();
432 _actualConnectionName = profile(
"Name");
438 QString mess =
"Failed to connect to database using profile " +
446 QString mess =
"Unable to create database from " + profile.
Name();
450 QString mess =
"Unknown exception while creating database from profile "
469 if(profile.
exists(
"Host")) {
470 db.setHostName(profile(
"Host"));
473 if(profile.
exists(
"DbName")) {
474 db.setDatabaseName(profile(
"DbName"));
477 if(profile.
exists(
"User")) {
478 db.setUserName(profile(
"User"));
481 if(profile.
exists(
"Password")) {
482 db.setPassword(profile(
"Password"));
485 if(profile.
exists(
"Port")) {
487 db.setPort(profile(
"Port").
toInt(&ok));
490 mess <<
"Invalid port number [" << profile(
"Port") <<
"] in profile "
491 << profile(
"Name") << ends;
496 if(profile.
exists(
"Options")) {
497 db.setConnectOptions(profile(
"Options"));
525 return (tables(QSql::Tables));
538 return (tables(QSql::Views));
550 return (tables(QSql::SystemTables));
564 QString errmess = message +
" - DatabaseError = " +